• springboot maven自定义jar包包名, 增加环境、时间版本号信息


    增加格式化时间的

    pom 文件下增加如下配置

     <properties>
            <maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
    		...
    </properties>
    ...
    <build>
    	<finalName>${project.artifactId}-${maven.build.timestamp}</finalName>
    	 <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering> //重点配置
                </resource>
    	</resources>
    	...
    </build>
    

    增加环境

    pom 文件增加如下配置

    <build>
    <finalName>${project.artifactId}-${profiles.active}</finalName>
    ...
    	<plugins>
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-resources-plugin</artifactId>
    			<configuration>
    				<delimiters>@</delimiters>
    				<useDefaultDelimiters>false</useDefaultDelimiters>
    			</configuration>
    		</plugin>
    	</plugins>
    </build>
    ...
    <profiles>
            <profile>
                <id>dev</id>
                <properties>
                    <profiles.active>dev</profiles.active>
                </properties>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
            </profile>
            <profile>
                <id>test</id>
                <properties>
                    <profiles.active>test</profiles.active>
                </properties>
    
            </profile>
            <profile>
                <id>prod</id>
                <properties>
                    <profiles.active>prod</profiles.active>
                </properties>
            </profile>
        </profiles>
    

    将配置文件中替换成对应的配置属性变量

    spring:
      # 激活环境配置
      profiles:
        active: @profiles.active@
    

    配置中的变量对应的就是 pom文件中的profile配置的属性。

    window 下运行可能存在编码问题。

    解决办法:

    在环境变量中,增加jvm 的环境变量 JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8

  • 相关阅读:
    Springboot构建问题集
    常用算法解析技巧总结
    Linux、Docker安装Nginx
    MySQL查询语句报错 sql_mode=only_full_group_by 问题
    MySQL按周统计 WEEK 实例
    IDEA注册码分享
    Mock测试接口
    Maven常用命令
    js中的for循环,循环次数会多出一次。当循环到最后一个的时候,循环还会继续,并且此时i就变成remove?
    vue .sync的理解
  • 原文地址:https://www.cnblogs.com/akashicbrother/p/16206919.html
Copyright © 2020-2023  润新知