使用Maven构建Spring Boot项目
IDEA专业版2024.1.4,Spring Boot3.4.3,Maven3.9.6,jdk21
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.3</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
点击maven,重新加载maven资源
package org.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class mavencreate {
public static void main(String[] args) {
SpringApplication.run(mavencreate.class, args);
}
}
编写完成后,尝试访问http://localhost:8080,显示页面如下
-
在resources文件下新建目录static,像5.1一样将五子棋.html移入静态资源,接着开始运行mavencreate.java启动代码。访问http://localhost:8080/五子棋.html
到这里,maven构建Spring Boot项目也成功啦,接下来开始在项目中加入控制器。