IDEA创建最简springboot项目
-
点击
File-->New-->Project
,在弹框中选择如下: -
点击
Next
后填写项目名称、包名等信息后点击OK: -
创建完成后,点击
File-->Settings
按需修改maven配置: -
打开pom.xml编辑修改如下:
-
添加springboot-web依赖:
<dependencies> <!-- SpringBoot Web容器 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
-
添加springboot依赖管理器:
<dependencyManagement> <dependencies> <!-- SpringBoot的依赖配置--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.2.12.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
-
重新加载maven工程:右键点击pom.xml,然后选择点击
Maven-->Reload project
-
-
创建包结构和各个类:
主类
MyDemoApplication
内容如下:配置文件
application.yml
内容如下:server: # 服务器的HTTP端口,默认为8080 port: 8082
-
运行项目:
在idea中打开主类
MyDemoApplication
,点击main方法左边的绿色三角形按钮即可启动运行。