[英]Spring Boot Maven Plugin – Exclude all dependencies
In my current project I'm using spring boot i want to exclude all dependencies.在我当前的项目中,我正在使用 spring boot 我想排除所有依赖项。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.3.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>a.b.testClass</mainClass>
<layout>ZIP</layout>
<excludeArtifactIds>*</excludeArtifactIds>
</configuration>
</plugin>
Ugly solution that seems to work is to put includes with not existing artifact:似乎有效的丑陋解决方案是将包含与不存在的工件:
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>abc</groupId>
<artifactId>abc</artifactId>
</include>
</includes>
</configuration>
Works on version 1.3.3 but there is not guarantee it won't change in next versions.适用于 1.3.3 版,但不保证在下一版本中不会更改。
Or, you can package everything yourself, there are instructions for ant: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-build-an-executable-archive-with-ant that can give you list of steps that you need to apply in maven.或者,你可以自己打包所有东西,蚂蚁有说明: http : //docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-build-an-executable- archive-with-ant可以为您提供需要在 maven 中应用的步骤列表。 So:
所以:
Include Main Class and Start Class in manifest:在清单中包含 Main Class 和 Start Class:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>org.springframework.boot.loader.PropertiesLauncher</mainClass> </manifest> <manifestEntries> <Start-Class>your.package.YourMainClass</Start-Class> </manifestEntries> </archive> </configuration> </plugin>
Skip adding dependencies in lib directory.跳过在 lib 目录中添加依赖项。
Add spring boot loader classes to the root: First you need dependency:将 spring boot loader 类添加到根目录:首先你需要依赖:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader</artifactId> <version>1.3.3.RELEASE</version> </dependency>
Then you need to unpack it:然后你需要解压它:
<plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>process-sources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-loader</artifactId> <outputDirectory>${project.build.directory}/classes</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin>
There might be a better way to put loader classes in root, but this works ok for my project.可能有更好的方法将加载器类放在 root 中,但这对我的项目来说没问题。
You can try this one.你可以试试这个。
<configuration>
<excludes>
<exclude>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclude>
</excludes>
</configuration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.