SpringBoot 动态打包
配置pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.19.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zuoye</groupId>
<artifactId>springboot-quickstart-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-quickstart-1</name>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
</properties> <!-- profile 配置切换: mvn clean install -P dev / prod / local / test / --> <profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
<bfxy.dynamic>2018-001</bfxy.dynamic>
</properties>
</profile> <profile>
<id>prod</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
<bfxy.dynamic>2018-002</bfxy.dynamic>
</properties>
</profile>
</profiles> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> <!-- 解解决maven update project 后版本降低为1.5的bug -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin> <!-- MAVEN打包时动态切换: mvn clean package -P prod/dev/local -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>default-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/classes</outputDirectory>
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
<delimiter>$</delimiter>
</delimiters>
<resources>
<!-- 打包时包含properties、xml -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<!-- 是否替换资源中的属性-->
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.yml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.yml</exclude>
<include>**/*.properties</include>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- 单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
<includes>
<include>**/*Test*.java</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<!-- 绑定到特定的生命周期之后,运行maven-source-pluin 运行目标为jar-no-fork -->
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> </project>
配置文件.properties
my-config.properties
bfxy.title=bfxy
bfxy.name=hello spring boot!
bfxy.attr=12345
# 读取pom.xml中的配置
bfxy.dynamic=$bfxy.dynamic$
application-dev.properties
server.port=8002
application-prod.properties
server.port=8003
application.properties
spring.application.name=/quickstart server.context-path=/qs
server.port=8001 custom.group=12345
custom.team=67890 #application-{}.properties //$spring.profiles.active$
#$ 通配符在pom.xml中指定
spring.profiles.active=prod
打包或运行哪个换将修改application.properties的spring.profiles.active=即可
SpringBoot 动态打包的更多相关文章
- ApkTool动态打包
引言: APK在推广的时候可能会须要动态打包APK.比方公布到不同渠道的时候,须要在manifest文件里改动渠道信息.或者app在推广的时候.须要在apk包里面加上推广人信息等. 环境变量: 1.J ...
- springboot项目打包运行
在springboot项目打包成jar包时,在cmd中使用java -jar **.jar时,浏览器无法访问. 解决方法:把项目改成war包项目,在pom文件中更改,并打成war包. 使用maven命 ...
- 将自己的SpringBoot应用打包发布到Linux下Docker中
目录 将自己的SpringBoot应用打包发布到Linux下Docker中 1. 环境介绍 2. 开始前的准备 2.1 开启docker远程连接 2.2 新建SpringBoot项目 3. 开始构建我 ...
- SpringBoot 项目打包后运行报 org.apache.ibatis.binding.BindingException
今天把本地的一个SpringBoot项目打包扔到Linux服务器上,启动执行,接口一访问就报错,但是在本地Eclipse中启动执行不报错,错误如下: org.apache.ibatis.binding ...
- springboot动态修改日志级别+权限认证
1. springboot动态修改日志级别+权限认证 1.1. 需求 网上找到的动态修改日志级别的方式,基本都是没有权限验证的,或者特地关闭权限验证,但也没给出加上验证的解决方式 修改日志等级也是一个 ...
- spring-boot子模块打包去掉BOOT-INF文件夹
1.spring-boot maven打包,一般pom.xml文件里会加 <plugin> <groupId>org.springframework.boot</grou ...
- libgdx学习记录19——图片动态打包PixmapPacker
libgdx中,opengl 1.x要求图片长宽必须为2的整次幂,一般有如下解决方法 1. 将opengl 1.x改为opengl 2.0.(libgdx 1.0版本后不支持1.x,当然不存在这个问题 ...
- vue+webpack多个项目共用组件动态打包单个项目
原文复制:https://www.jianshu.com/p/fa19a07b1496 修改了一些东西,因为sh脚本不能再window电脑执行,所以改成了node脚本.这是基于vue-cli2.0配置 ...
- SpringBoot项目打包成jar后,启动脚本
将springboot项目打包成jar后,上传至服务器,每次都需要手敲命令,重新部署项目,可将这些命令写入脚本中,直接运行. 启动脚本(start.sh): CUR_PATH=$(cd "$ ...
随机推荐
- 使用匿名函数给setInterval()传递参数
在使用JScript的时候,我们有时需要间隔的执行一个方法,比如用来产生网页UI动画特效啥的.这是我们常常会使用方法setInterval或setTimeout,但是由于这两个方法是由脚本宿主模拟出来 ...
- 浏览器组成、线程及event loop
浏览器组成 User interface: a. Every part of the browser display, except the window. b. The address bar, b ...
- 关于 webpack 跨域
一.使用 http-proxy-middleware 代理 安装 http-proxy-middleware 依赖 在src 目录下 新建一个 setupProxy.js文件 // 引用依赖 va ...
- 推荐js库: underscore
Underscore封装了常用的JavaScript对象操作方法,用于提高开发效率. 之间没用他之前,自己写,那是相当的酸爽. 如循环处理: for(var i=0;i<data.length; ...
- Android 虚拟多开系列一——技术调研
参考链接:http://weishu.me Github源码链接: 国内Xposed框架源码链接 VirtualAp ...
- 爬虫day03之scrapy安装与使用
参考博客 技术问题不要问,业务问题可以问是不是有一种更好的方法? scrapy windows安装 1. 安装scrapy 参考博客 https://www.cnblogs.com/wupeiqi/a ...
- ExpressRoute 概述
使用 Azure ExpressRoute 可通过连接服务提供商所提供的专用连接,将本地网络扩展到 Azure 云.使用 ExpressRoute 可与 Azure云服务建立连接. 可以从任意位置之间 ...
- 关于v$rowcache
关于v$rowcache column parameter format a21column pct_succ_gets format 999.9column updates format 999,9 ...
- Python学习---django之ORM语法[对象关系映射]180124
ORM语法[对象关系映射] ORM: 用面向对象的方式去操作数据库的创建表以及增删改查等操作. 优点:1 ORM使得我们的通用数据库交互变得简单易行,而且完全不用考虑该死的SQL语句.快速开发. 2 ...
- 乘风破浪:LeetCode真题_015_3Sum
乘风破浪:LeetCode真题_015_3Sum 一.前言 关于集合的操作,也是编程最容易考试的问题,比如求集和中的3个元素使得它们的和为0,并且要求不重复出现,这样的问题该怎么样解决呢? 二.3Su ...