zoukankan      html  css  js  c++  java
  • 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包.

  • 相关阅读:
    def __unicode__(self): 或 def __str__(self):
    通过ORM创建数据库链接
    单表查询的API介绍
    数据库的查看以及建立数据库
    基础数据类型
    表单及数据库
    flag标志位
    Console面板小技巧:
    angular入门试水-基本指令理解
    构造方法
  • 原文地址:https://www.cnblogs.com/wym789/p/11505591.html
Copyright © 2011-2022 走看看