1. 先将项目的build.gradle中添加以下代码。
apply plugin: 'maven'
group 'com.xxxx'
version '0.0.1'
sourceCompatibility = 1.8
task writeNewPom << {
pom {
project {
inceptionYear '2020'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("pom.xml")
}
参考文档:https://my.oschina.net/sunyouling/blog/1615920
2.将生成的pom.xml文档修改。
3.修改pom文件,解决包冲突和打jar包问题
4.现在启动看看是否报错,如果报因为java1.5编译失败错误,我用的是idea,所以我说idea的配置:
5.现在启动应该不会报错了,接下来就是打包能成功,但Java- jar xxxx.jar 命令时提示“没有主清单属性”。我的解决是:在pom.xml中添加代码:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>