惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
MyScale Blog
MyScale Blog
Recent Announcements
Recent Announcements
N
Netflix TechBlog - Medium
GbyAI
GbyAI
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
Martin Fowler
Martin Fowler
腾讯CDC
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
J
Java Code Geeks
WordPress大学
WordPress大学
P
Proofpoint News Feed
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog

博客园 - 李学斌

写单元测试,我不认为是件容易的事 服务治理咋这么难?我想得换个治法了。 百度大会见解 李学斌:论复杂系统中的应用间协作V3 大视角、大方向、大问题、大架构:(结局)解决问题的出发点 大视角、大方向、大问题、大架构:(二)应用的相关问题 大视角、大方向、大问题、大架构:(一)信息时代下的管理 信息时代下,如何看待技术与理论 狼的架构暗示 狼群的架构暗示 基因与架构 由“I”到“T” 产品的臃肿过程 我们是在开发产品还是项目? 未来电子商务,未来的超市 创业期的软件开发管理(二) 创业期的软件开发管理(一) 平台架构--用户系统 平台架构——体系结构
maven spring profile 协同
李学斌 · 2014-05-06 · via 博客园 - 李学斌

  请在网上查相关的使用情景,这里直接上要点。另外,可能不只一种方法,但这里只有一种。

  1、POM.XML片段,使web.xml文件中有关活跃spring profile的内容可以被maven自动替换

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>
                            <includes>
                                <include>**/web.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                </configuration>
            </plugin>

  2、POM.XML片段,在profile中自定义属性。注意id与属性值的一致

            <profile>
                <id>test</id>
                <properties>
                    <profile.active>test</profile.active>
                        ……
                </properties>
            </profile>
            <profile>
                <id>dev</id>
                <properties>
                    <profile.active>dev</profile.active>
                        ……
                </properties>
            </profile>    

  3、web.xml片段,使用maven中定义的属性

    <context-param>
        <param-name>spring.profiles.active</param-name>
        <param-value>${profile.active}</param-value>
    </context-param>

  4、spring配置文件,定义各种Beans的所适用的profile。

    <beans profile="test,online">
    </beans>
    <beans profile="dev">
    </beans>