SpringBoot骨架的生成方法
- 去官网生成:https://start.spring.io/
- 通过idea生成。
SpringBoot默认的parent依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
去掉默认的parent依赖
- 添加一个dependencyManagement下的dependency
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
- 修改spring-boot-maven-plugin插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.4</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
简单测试
@SpringBootApplication
@RestController
public class Learn02Application {
public static void main(String[] args) {
SpringApplication.run(Learn02Application.class, args);
}
@RequestMapping("/hello")
public String hello(){
return "hello";
}
}
- 使用curl命令访问。

- 浏览器访问 http://localhost:8080/hello