liangcmwn / docs

mydocs on git
0 stars 0 forks source link

Spring Boot 打包分离 第三方 jar #13

Open liangcmwn opened 5 years ago

liangcmwn commented 5 years ago

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>
liangcmwn commented 5 years ago

Gradle :

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

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