• Springboot 配置文件和lib 独立打包;jar文件


       springboot jar 打包时候文件非常大;不利于更新和升级;

    1、Pom文件

    <build>
    <!-- <plugins>

    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
    <excludes>
    <exclude>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    </exclude>
    </excludes>
    <fork>true</fork>&lt;!&ndash;重要&ndash;&gt;
    </configuration>
    </plugin>



    </plugins>-->

    <plugins>
    <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>
    <!--拷贝第三方依赖文件到指定目录-->
    <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>
    <!--target/lib是依赖jar包的输出目录,根据自己喜好配置-->
    <outputDirectory>target/lib</outputDirectory>
    <excludeTransitive>false</excludeTransitive>
    <stripVersion>false</stripVersion>
    <includeScope>runtime</includeScope>
    </configuration>
    </execution>
    </executions>
    </plugin>

    </plugins>
    </build>


    2、将package后target目录下的jar包和lib文件夹;以及原项目的resourse文件夹复制到一个单独文件夹app ;结构如下图

    3、启动的时候  cmd命令:java -jar -Dloader.path=resources,lib vueblog-0.0.1-SNAPSHOT.jar



  • 相关阅读:
    Exection throws和throw
    Exection(二)
    JAVA-Exception
    IDEA初见---输出HelloWorld,并打包成jar包
    Centos6.5安装Tomcat
    Centos6.5下装ZooKeeper
    LInux下装jdk
    python作业高级FTP
    tcp黏包
    计算器
  • 原文地址:https://www.cnblogs.com/Ken2018/p/15054147.html
Copyright © 2020-2023  润新知