在我目前的项目中,我正在使用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>
答案 0 :(得分:2)
似乎有用的丑陋解决方案是将包含不存在的工件:
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>abc</groupId>
<artifactId>abc</artifactId>
</include>
</includes>
</configuration>
适用于版本1.3.3,但不保证在下一版本中不会更改。
或者,你可以自己打包一切,有蚂蚁的说明: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-build-an-executable-archive-with-ant 这可以为您提供在maven中应用的步骤列表。所以:
在清单中包含主类和起始类:
<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>
跳过在lib目录中添加依赖项。
将spring boot loader类添加到root:首先需要依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
<version>1.3.3.RELEASE</version>
</dependency>
然后你需要解压缩它:
<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>
可能有更好的方法将加载程序类放在root中,但这对我的项目来说没问题。
答案 1 :(得分:-1)
你可以试试这个。
<configuration>
<excludes>
<exclude>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclude>
</excludes>
</configuration>