liangcmwn/docs

Spring Boot 打包分离 第三方 jar

Opened this issue · 1 comments

java -jar -Dloader.path=.,lib test.jar

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<execution>
			<id>copy-dependencies</id>
			<phase>package</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>target/lib</outputDirectory>
				<excludeTransitive>false</excludeTransitive>
				<stripVersion>false</stripVersion>
				<includeScope>runtime</includeScope>
			</configuration>
		</execution>
	</executions>
</plugin>
<plugin>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-maven-plugin</artifactId>
	<configuration>
		<layout>ZIP</layout>
		<includes>
			<include>
				<groupId>non-exists</groupId>
				<artifactId>non-exists</artifactId>
			</include>
		</includes>
	</configuration>
</plugin>

Gradle :

bootJar {
	classifier = 'boot'
	excludes = ["*.jar"]
}

task copyToLib(type: Copy) {
    into "$buildDir/libs/lib"
    from configurations.runtime
}