0
在编译我的可执行jar时,我的项目的程序集结束了,不仅包括在可执行jar上的spring引导依赖项,还包括目标lib文件夹,其中所有其他模块都是放置。此后我的可执行的JAR模块POM:spring-boot-maven-plugin重新包装依赖也
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>agatha-pdcProvider</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.organization</groupId>
<artifactId>parent_pom</artifactId>
<version>1.6.2-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.7</java.version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.1.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
和父POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.organization</groupId>
<artifactId>agatha</artifactId>
<version>1.6.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>NAME</name>
<parent>
<groupId>com.general</groupId>
<artifactId>company-pom</artifactId>
<version>2.3</version>
<relativePath></relativePath>
</parent>
<url>http://maven.apache.org</url>
<modules>
<module>agatha-anotherModule</module>
<module>agatha-pdcProvider</module>
<module>agatha-assembly</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.organization</groupId>
<artifactId>agatha-another</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.organization</groupId>
<artifactId>agatha-pdcProvider</artifactId>
<version>${project.version}</version>
</dependency>
<!--pdcProvider-->
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${svn_revision}</SCM-Revision>
<Timestamp>${maven.build.timestamp}</Timestamp>
<Branch>${svn_url}</Branch>
<Baseline>${baseline}</Baseline>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
最后,我组装POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.organization</groupId>
<artifactId>agatha</artifactId>
<version>1.6.2-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>agatha-assembly</artifactId>
<packaging>pom</packaging>
<name>agatha-assembly</name>
<dependencies>
<dependency>
<groupId>com.organization</groupId>
<artifactId>agatha-anotherModule</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<filters>
<filter>src/main/assembly/filter.properties</filter>
</filters>
<finalName>agatha</finalName>
<ignorePermissions>true</ignorePermissions>
<descriptors>
<descriptor>src/main/assembly/assembly-release.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
<fileName>${project.artifactId}</fileName>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>target-profile</id>
<dependencies>
<dependency>
<groupId>eu.unicredit.rae</groupId>
<artifactId>agatha-pdcProvider</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly-hvb-prod.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
如何避免在我的常规lib文件夹中包含fat jar依赖项。 –