生成的Spring Boot项目的parent是spring-boot-starter-parent,但是实际开发中我们项目往往需要继承我们自己的平台的父parent。
去除Spring Boot 默认parent,可以添加如下配置!
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
更换父项目依赖后,可以正常运行,但是打出的包是不包含依赖的;
使用java -jar 执行会报错:jar中没有主清单属性
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
添加后再次打包, 一切正常。