Maven Profile标签
Maven Profiles标签可以针对不同的环境来使用不同的配置文件
在发布的时候可以用
- mvn release -p product
- mvn release -p test
- mvn release -p dev
默认本地deploy的时候用的是dev的配置 文件
在编译项目的过程中,资源中的占位符${}会被替换成配置文件中的值,如果没有进行替换,则会出现问题。
<profiles>
<profile>
<id>product</id>
<build>
<filters>
<filter>src/main/resources/release.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/resources/dev.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>test</id>
<build>
<filters>
<filter>src/main/resources/test.properties</filter>
</filters>
</build>
</profile>
</profiles>
如果编译时资源文件中的占位符没有被替换成配置文件中的值,则一般会抛出异常:
Circular placeholder reference 'db.url' in property definitions
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)
at com.showjoy.core.configure.SecPropertyPlaceholderConfigurer.processProperties(SecPropertyPlaceholderConfigurer.java:50)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1960)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
这时的处理办法是,把target中编译好的文件clean掉,重新用maven build下,确保资源文件中的占位符没有被替换成配置文件中的值
Maven Profile标签的更多相关文章
- 项目实现不同环境不同配置文件-maven profile
最近接触的项目都是在很多地方都落地的项目,需要支持不同的环境使用不同的配置文件.一直以来都以为是人工的去写不同的配置文件,手动的去修改运用的配置文件.感觉自己还是太low呀.maven的使用的还停留在 ...
- 使用maven profile实现多环境可移植构建(转自CSDN)
使用maven profile实现多环境可移植构建 标签: maven profilemaven自动构建maven自动部署maven可移植构建持续集成 2014-04-25 23:37 26905人阅 ...
- How to activate maven profile inside eclipse
How to activate maven profile inside eclipse Normally maven is use for project dependency management ...
- 通过maven profile 打包指定环境配置
背景 最近换了个新公司接手了一个老项目,然后比较坑的是这个公司的项目都没有没有做多环境打包配置,每次发布一个环境都要手动的去修改配置文件.今天正好有空就来配置下. 解决这个问题的方式有很多,我这里挑选 ...
- maven profile实现多环境配置
每次项目部署上线都需要手动去修改配置文件(比如数据库配置,或者一个自定义的配置)然后才能打包,很麻烦,网上找到 maven profile可以完成这个工作,记录如下: 环境:eclipse + spr ...
- 在eclipse激活maven profile配置
profile简介 profile可以让我们定义一系列的配置信息,然后指定其激活条件.这样我们就可以定义多个profile,然后每个profile对应不同的激活条件和配置信息,从而达到不同环境使用不同 ...
- CAS (13) —— CAS 使用Maven Profile支持多环境编译
CAS (13) -- CAS 使用Maven Profile支持多环境编译 摘要 CAS 使用Maven Profile支持多环境编译 版本 tomcat版本: tomcat-8.0.29 jdk版 ...
- maven profile 优先级
maven profile是有优先级别 也就是说在setting.xml的profile优先级比pom中同名的profile高. 可以使用 mvn help:active-profiles 这个命令是 ...
- 记录一次诡异的Maven Profile不生效的问题
记录一次诡异的Maven Profile不生效的问题 现象 maven 打包之后,复制的 profile对应的resource文件总是不正确的. 即便是加了 mvn clean package -P ...
随机推荐
- Qt学习 之 Socket通信(世界上最简单的例子了)
最近写大作业用到Qt的Socket部分,网上关于这部分的资料都太过复杂,现在总结一下一些简单的应用.有机会可以给大家讲讲用Socket传送文件的代码. 这里主要讲解如何实现TCP和UDP的简单通信. ...
- 详解Spring中的CharacterEncodingFilter
在项目中有很多让人头疼的问题,其中,编码问题位列其一,那么在Spring框架中是如何解决从页面传来的字符串的编码问题的呢?下面我们来看看Spring框架给我们提供过滤器CharacterEncodin ...
- Yii框架下不同contoller之间的方法调用
一个contoller CustomerController里怎么调用另一个controller里的action,Acontoller调用SiteContoller的actionShow($id), ...
- Linux kernel ‘ip6_sk_dst_check’函数拒绝服务漏洞
漏洞名称: Linux kernel ‘ip6_sk_dst_check’函数拒绝服务漏洞 CNNVD编号: CNNVD-201307-070 发布时间: 2013-07-05 更新时间: 2013- ...
- 「Poetize6」Candle
描述 蜡烛商店中有10种蜡烛,形状分别是0~9这10个数字,不过对于每种蜡烛,商店的存货量仅有一根.另外,忘川沧月已经有了一个"+"形状的蜡烛.忘川沧月想购买一些蜡烛,使得他的家族 ...
- Ubuntu 14.04 Remmina远程桌面连接Windows计算机
可以在/usr/share/applications/目录下启动Remmina远程桌面客户端或者直接在Dash中搜索Remmina即可 启动后如下图,可以新建,复制,编辑,删除远程桌面客户端 选择新建 ...
- 2B The least round way
题目大意: 一个n*n的矩阵,从矩阵的左上角开始,每次移动到下面或者右面,移动到右下角结束. 要求走的路径上的所有数字乘起来,乘积得到的值后面的0最少. #include <iostream ...
- 数学(欧拉函数):UVAOJ 11426 GCD - Extreme (II)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAIAAABnsVYUAAAgAElEQVR4nOzdPW7zvII/bG1gCi9gKq ...
- lightoj 1198 最大权重匹配
题目链接:http://lightoj.com/volume_showproblem.php?problem=1198 #include <cstdio> #include <cst ...
- python用paramiko将执行的结果存入excel表格
一.paramiko 利用paramiko可以远程控制服务器,上传和下载文件. 1.paramiko密码登录方式: #!/usr/bin/env python #coding:utf-8import ...