使用IDEA创建SpringBoot项目的方法步骤

您所在的位置:网站首页 idea打开springboot 使用IDEA创建SpringBoot项目的方法步骤

使用IDEA创建SpringBoot项目的方法步骤

2024-07-18 00:21:21| 来源: 网络整理| 查看: 265

1.打开IDEA,创建新项目,选择Spring Initializr

2.输入Artifact

3.勾选Web

4.点击finish完成

5.进入项目,可以将以下内容删除

pom.xml文件:

4.0.0 com.example springbootdemo 0.0.1-SNAPSHOT jar springbootdemo Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 1.5.2.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin

6.创建一个HelloController

package com.example; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @RequestMapping("/hello") public String hello() { return "hello,this is a springboot demo"; } }

7.程序自动生成的SpringbootdemoApplication,会有一个@SpringBootApplication的注解,这个注解用来标明这个类是程序的入口

package com.example; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; //入口 @SpringBootApplication public class SpringbootdemoApplication { public static void main(String[] args) { SpringApplication.run(SpringbootdemoApplication.class, args); } }

@SpringBootApplication开启了Spring的组件扫描和springboot的自动配置功能,相当于将以下三个注解组合在了一起

(1)@Configuration:表名该类使用基于Java的配置,将此类作为配置类

(2)@ComponentScan:启用注解扫描

(3)@EnableAutoConfiguration:开启springboot的自动配置功能

8.运行SpringbootdemoApplication类

测试:

在地址栏中输入http://localhost:8080/hello

9.使用启动jar包的方式启动

(1)首先进入项目所在目录,如果是mac系统在项目上右键,选择Reveal in Finder,Windows系统在项目上右键选择Show in Explorer,即可打开项目所在目录

(2)打开终端,进入项目所在目录

cd /Users/shanml/IdeaProjects/SpringbootDemo

输入mvn install,构建项目

(3)构建成功后,在项目target文件夹下会多出一个jar包

(4)使用java -jar springbootdemo-0.0.1-SNAPSHOT.jar 

启动jar包即可

参考:

廖师兄:两小时学会Springboot

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:从零开始使用IDEA创建SpringBoot项目(图文)在IDEA中创建跑得起来的Springboot项目idea创建springboot项目和springcloud项目的详细教程IDEA创建springboot + mybatis项目全过程(步骤详解)IDEA2020.2创建springboot项目卡死在reading maven project的问题IDEA创建SpringBoot的maven项目的方法步骤IDEA教程创建SpringBoot前后端分离项目示例图解在idea中创建SpringBoot项目用IDEA创建SpringBoot项目的详细步骤记录


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭