Pan*_*kaj 10 java maven spring-boot spring-boot-maven-plugin
我正在使用spring-boot-maven-plugin
我的REST服务打包.我正在用mvn clean install
或建造罐子mvn clean package
.在我反编译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>
Run Code Online (Sandbox Code Playgroud)
当我运行spring boot时,java -jar myapp.jar -Drun.jvmArguments="-Dspring.profiles.active=qal"
我正在为许多类获取ClassNotFoundException.很明显,工件没有像预期的那样构建.但是,如果我使用maven启动spring boot应用程序,./mvnw spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=qal"
我猜它会找到目标文件夹中的所有依赖项,因此工作正常.如何修复构建问题,以便我可以使用java -jar命令启动应用程序.
编辑:这是多模块maven项目
看来您使用了错误的命令。mvn clean package
是maven命令,应使用命令“ repackage”,用于
重新打包现有的JAR和WAR归档文件,以便可以使用java -jar从命令行执行它们
正如这里提到的https://docs.spring.io/spring-boot/docs/current/maven-plugin/repackage-mojo.html
或者可能是插件配置问题。刚刚检查过:它适用于spring-boot-maven-plugin-2.0.0.RELEASE
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5789 次 |
最近记录: |