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


    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包.

  • 相关阅读:
    shell脚本的常用参数
    Qt中使用Protobuf简单案例(Windows + msvc)
    使用PicGo和Typora写Markdown
    CentOS7安装protobuf(C++)和简单使用
    protobuf编译、安装和简单使用C++ (Windows+VS平台)
    protocol buffers 文档(一)-语法指导
    Base64编码和其在图片的传输的应用
    Qt程序打包发布
    Qt中的Label和PushButton背景图自动缩放设置
    TCP的粘包和拆包问题及解决
  • 原文地址:https://www.cnblogs.com/wym789/p/11505591.html
Copyright © 2020-2023  润新知