码迷,mamicode.com
首页 > 编程语言 > 详细

springboot使用maven命令打包jar及配置文件配置

时间:2019-09-11 13:48:54      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:eset   prefix   app   ring   classpath   version   basedir   include   项目文件   

sspringboot项目如果不想每次修改配置文件就要重新打包jar的话,可以进行以下配置进行打包

1.技术图片在resources下新建assembly文件夹package.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>package</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>true</includeBaseDirectory>
    <fileSets>
        <!-- 把项目相关的说明文件,打包进zip文件的根目录 -->
        <!-- <fileSet>
            <directory>${project.basedir}</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>README*</include>
                <include>LICENSE*</include>
                <include>NOTICE*</include>
                <include>build.info</include>
            </includes>
        </fileSet> -->

        <fileSet>
            <directory>${project.basedir}/src/main/resources</directory>
            <outputDirectory></outputDirectory>
        </fileSet>

        <!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 -->
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

2.在pom中配置下面代码

 

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix></classpathPrefix>
                            <mainClass>com.xx.xx.xxxxApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <!-- The configuration of the plugin -->
                <configuration>
                    <!-- Specifies the configuration file of the assembly plugin -->
                    <descriptors>
                        <descriptor>src/main/resources/assembly/package.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

然后在项目文件夹下shift+右键打开命令行窗口输入:mvn package -DskipTests 回车,会在target文件夹下生成zip包.

springboot使用maven命令打包jar及配置文件配置

标签:eset   prefix   app   ring   classpath   version   basedir   include   项目文件   

原文地址:https://www.cnblogs.com/wym789/p/11505591.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!