搭建SpringBoot工程的两种模式
springBoot参考文档:
链接:https://pan.baidu.com/s/1MEIEa2WKMxfmwRwn8hGJHA
提取码:7och
1.让自己的父工程继承SpringBoot
创建一个自己的父工程,在pom中引入<parent>
标签属性
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
然后开发自己的子模块
2.如果自己的父模块没有继承SpringBoot
如果工程中只有一个或者少量的模块是使用了SpringBoot框架,并且子模块已经继承了自己开发的父模块,这时候想要使用SpringBoot的功能
spring-Maven插件参考文档:
链接:https://pan.baidu.com/s/1KD3Zhwt1BzPYoFqbUHksmg
提取码:kyee
- 版本控制
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
- 配置插件:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.4.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- 然后配置SpringBoot的一些启动器
- 开发自己的类
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class,args);
}
}
- resource文件下创建配置文件
application.properties和static文件夹