[英]copy dependencies in a spring boot application
I have spring boot application where during maven install, I want it to create a jar and copy the dependencies into a lib folder. 我有spring boot应用程序,在maven安装期间,我希望它创建一个jar并将依赖项复制到lib文件夹中。 I am trying to use these two maven plugins that are working fine in other maven projects but doesn't work in a spring boot application. 我正在尝试使用这两个maven插件,这些插件在其他maven项目中工作正常,但在spring引导应用程序中不起作用。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<useDefaultManifestFile>true</useDefaultManifestFile>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>xxx.Main</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
What is happening is that the jar gets created even if the maven-jar-plugin is omitted. 发生的事情是,即使省略了maven-jar-plugin,jar也会被创建。 And it doesn't do anything with the maven-dependency-plugin. 并且它对maven-dependency-plugin没有任何作用。 So it pretty much ignores both these plugins. 所以它几乎忽略了这两个插件。
I put the Spring Boot plugin after copy-dependencies and work fine! 我把Spring Boot插件放在copy-dependencies之后,工作正常!
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
Notes: I clean Maven repository to work! 注意:我清理Maven存储库工作!
I think you should try Spring boot + Gradle: Spring boot Gradle 我想你应该尝试Spring boot + Gradle: Spring boot Gradle
In build.gradle file, you can customize the build process and copy your dependencies into lib folder by using gradle copy method. 在build.gradle文件中,您可以使用gradle copy方法自定义构建过程并将依赖项复制到lib文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.