首页 > 其他分享 >maven多环境打包部署

maven多环境打包部署

时间:2024-02-21 14:25:35浏览次数:18  
标签:部署 profiles maven application active true properties 打包

1、多环境properties文件创建
准备properties配置文件
在application.properties中配置标识环境
[email protected]@

在Spring Boot中多环境配置文件名需要满足application-{profiles.active}.properties的格式,其中{profiles.active}对应你的环境标识。

#环境配置
[email protected]@

2、pom配置

<profiles>
    <profile>
        <id>tst</id>
        <properties>
            <profiles.active>tst</profiles.active>
        </properties>
    </profile>
    <profile>
        <!-- uat -->
        <id>uat</id>
        <properties>
            <profiles.active>uat</profiles.active>
        </properties>
        <!-- 是否默认 true表示默认-->
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>prd</id>
        <properties>
            <profiles.active>prd</profiles.active>
        </properties>
    </profile>
</profiles>
<build>
    <!-- 打包后包名称 -->
    <finalName>getJobData</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.java.springboot.Application</mainClass>
                <fork>true</fork>
                <addResources>true</addResources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>


    </plugins>

    <!-- mybatis配置文件 -->
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>mapper/*.xml</include>
            </includes>
        </resource>

        <!--排除配置文件-->
        <resource>
            <directory>src/main/resources</directory>
            <!--先排除所有的配置文件-->
            <excludes>
                <!--使用通配符,当然可以定义多个exclude标签进行排除-->
                <exclude>application*.properties</exclude>
            </excludes>
        </resource>

        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>application.properties</include>
                <include>application-${profiles.active}.properties</include>
            </includes>
        </resource>
    </resources>
</build>

filetering是一个boolean变量,作用是将资源文件中的占位符替换成对应的值。
filtering为true,开启过滤,替换directory下的文件中的参数(eg. ${name})。会把过滤的文件打到classpath下
filtering为false,不过滤,不会进行占位符替换。会把不需要过滤的文件打到classpath下
如果不做filtering配置,pom中的${profiles.active}是可以被解析替换的。但是resource指定的资源文件application.properties中的@profiles.active@是不会被解析替换的

3、打包
在idea中,勾选不同的profile环境配置,就可以打包不同环境的jar包或war包
指定环境类型打包使用,比如使用-P指定为uat ,-DskipTests=true 跳过整个测试阶段,包括编译测试代码和运行测试用例
mvn compile package -DskipTests=true -Puat

标签:部署,profiles,maven,application,active,true,properties,打包
From: https://www.cnblogs.com/swjdss/p/18025088

相关文章

  • Bubbliiiing版本yolov7 c++opencv dnn部署
    使用B导的yolov7代码部署,代码地址:https://github.com/bubbliiiing/yolov7-pytorch 模型的的训练看B导即可,up主地址:Bubbliiiing的博客_CSDN博客-神经网络学习小记录,睿智的目标检测,有趣的数据结构算法领域博主 模型训练完成之后,在predict.py中设置mode="export_onnx"即可......
  • 使用NSSM 把 .net core 开发的控制台程序部署成windows 服务
    0.背景应工作需要需要写个对指定网站附件进行监控,发现有新附件时需要程序进行自动下载,程序设计使用技术如下:开发语言:.net8C# 定时任务:Quartzhttp请求和下载:HttpClienthtml解析:HtmlAgilityPack服务部署工具:NSSM 1.什么是NSSM在windows平台NSSM可以把bat、exe等文件......
  • 使用python进行自动化备份和部署
    1、代码文件deploy.pyimportosfromdatetimeimportdatetimeimportshutilimportsysimportwin32serviceutilimportwin32serviceimporttimeimporttkinterastk#fromtkinterimportfiledialogimportconfigparserimportloggingimportctypes#创建......
  • SpringBoot使用git-commit-id-maven-plugin打包
    简介git-commit-id-maven-plugin是一个maven插件,用来在打包的时候将git-commit信息打进jar中。这样做的好处是可以将发布的某版本和对应的代码关联起来,方便查阅和线上项目的维护。至于它的作用,用官方说法,这个功能对于大型分布式项目来说是无价的。功能你是否经常遇到这样的......
  • JeecgBoot集成宝兰德AppServer部署方案
    JeecgBootVersion:3.5+版本后台采用war包的打包方案。后台JeecgBoot项目打war包打war包前需要对项目进行微小改动:1、jeecg-system-start/pom.xml文件中1.1、项目格式设置为war<packaging>war</packaging>1.2、pom.xml文件删除插件spring-boot-maven-plugin下面配置......
  • 基于OpenVINO 2022.1 C++ API部署YOLOv7预训练模型
    任务背景作为视觉应用中最常见的任务之一,目标检测一直是各类新模型刷榜的必争之地,其中就以YOLO系列的网络结构最为突出。YOLO的全称是youonlylookonce,指只通过one-stage的方式需要“浏览一次”就可以识别出图中的物体的类别和位置。近期YOLO官方团队又放出新版本——YOLOv7,速......
  • Linux下使用docker部署vue项目
    通过nginx镜像部署关于前端vue项目部署:使用npm打包创建nginx容器dockerrun-d--nameadmin_portal-p9091:80nginx将dist目录下的所有文件拷贝到容器的/usr/share/nginx/html目录下,这个是html文件的默认读取路径dockercp./admin_portal:/usr/share/nginx/html/......
  • linux下部署MySQL服务
    linux下部署MySQL服务1、安装sudo-s调整为root下用户角色运行以下命令安装MySQL,输入Y继续sudoaptinstallmysql-server2、启动systemctlstartmysqld设置MySQL开机自启动(可选)systemctlenablemysqld3、检查运行状态systemctlstatusmysqld4、配置MySQL用户......
  • 记录一次grpc打包的坑
    GRPC打包的坑今天做的项目需要用到grpc,然后需要打jar包进行引用,打包的时候却失败了报了protocdidnotexitcleanly.Reviewoutputformoreinformation.--grpc-java_out:protoc-gen-grpc-java:Thesystemcannotfindthepathspecified.的相关错误很明显就是路径的问......
  • 【LLMOps】Triton + TensorRT-LLM部署QWen
    背景TensorRT-LLM是Nvidia官方推出的大模型推理加速框架,目前只对部分显卡型号有做定制加速。最近新出的ChatwithRTX也是基于TensorRT-LLM进行的本地推理。TensorRT-LLM支持PagedAttention、FlashAttention、SafeTensor等手动,某些社区号称吞吐能力测试结果超过vLLM。准备显......