我正在使用 spring-boot-maven-plugin
打包我的REST服务 . 我正在使用 mvn clean install
或 mvn clean package
构建jar . 在我反编译jar之后,我没有发现添加任何依赖项(我希望它是一个包含所有依赖项的胖jar)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.9.RELEASE</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>true</executable>
<finalName>myapp</finalName>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
当我使用 java -jar myapp.jar -Drun.jvmArguments="-Dspring.profiles.active=qal"
运行spring boot时,我明白了工件没有按预期构建 . 但是,如果我使用maven ./mvnw spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=qal"
启动spring boot应用程序,我想,它会找到目标文件夹中的所有依赖项,因此工作正常 . 如何修复构建问题,以便我可以使用java -jar命令启动应用程序 .
编辑:这是多模块maven项目
2 回答
看来你使用了错误的命令 .
mvn clean package
是maven命令,你应该使用命令'repackage',它用于正如它在这里提到的https://docs.spring.io/spring-boot/docs/current/maven-plugin/repackage-mojo.html
或者可能是插件配置问题 . 刚检查:它适用于
spring-boot-maven-plugin-2.0.0.RELEASE
使用这个