IDE 都支持的使用Spring的项目创建向导 快速创建Spring Boot项目:
选择我们需要的模块,向导会联网创建Spring Boot;
默认生成的Spring Boot项目:
主程序已经生成好了,我们只需要我们自己的逻辑
resourrces文件夹中的目录结构:
static:保存所有的静态资源;js css images;
templates:保存所有的模板页面;(Spring Boot默认jar包使用嵌入式Tomcat,默认不支持JSP页面;可以使用模板引擎(freemarker,thymeleaf)
application.properties:Spring Boot应用的配置文件;可以修改一些默认配置;比如修改8080端口号


快速创建Spring Boot项目步骤:
1.创建Spring Initialize

2.进行选项

3.这里选择需要的依赖

4.完成创建

创建完成后:会自动给我们加载相应的依赖,和创建相应的主程序
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.hp</groupId>
<artifactId>spring-boot-test1-quick</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-test1-quick</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
本文详细介绍如何使用IDE内置的Spring Initialize向导快速创建SpringBoot项目。从选择所需模块到生成主程序,再到理解默认目录结构,如static、templates及application.properties等。同时,文章还列举了Maven配置及依赖项,包括spring-boot-starter-parent、spring-boot-starter-web及spring-boot-starter-test。
954

被折叠的 条评论
为什么被折叠?



