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

  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>

maven spring profile 协同的更多相关文章

  1. Maven+Spring Profile实现生产环境和开发环境的切换

    第一步 Maven Profile配置 <profiles> <profile> <id>postgres</id> <activation> ...

  2. Maven 整合 spring profile实现多环境自动切换

    Maven 整合 spring profile实现多环境自动切换 时间:2014-03-19 15:32来源:Internet 作者:Internet 点击:525次 profile主要用在项目多环境 ...

  3. Spring boot项目maven的profile多环境配置不自动替换变量的问题解决

    Spring boot项目maven的profile多环境配置不自动替换变量的问题解决   在网上找了好久,配置都很简单,可是我的程序就是不能自动替换变量,最终单独测试,发现原来是引用spring b ...

  4. Maven+Spring

    Maven+Spring 关于Maven Maven是一个用于项目构建的工具,通过它便捷的管理项目的生命周期.即项目的jar包依赖,开发,测试,发布打包. 做过.NET的人应该会联想到Nuget,是的 ...

  5. ssm maven spring AOP读写分离

    ssm maven spring AOP读写分离 总体流程 配置最开始写在pom.xml文件,解析到数据库配置文件,再解析到spring配置文件. 自定义注解DataSource:通过这个注解并且在s ...

  6. Maven之profile实现多环境配置动态切换

            一般的软件项目,在开发.测试及生产等环境下配置文件中参数是不同的.传统的做法是在项目部署的时候,手动修改或者替换这个配置文件.这样太麻烦了,我们可以用Maven的profile来解决这 ...

  7. Java EE 学习(5):IDEA + maven + spring 搭建 web(1)

    参考:http://www.cnblogs.com/lonelyxmas/p/5397422.html http://www.ctolib.com/docs-IntelliJ-IDEA-c--1590 ...

  8. 补习系列(22)-全面解读 Spring Profile 的用法

    目录 一.简介 二. 区分Bean对象 三. 设置Profile 3.1 WebApplicationInitializer接口 3.2 通过 web.xml定义 3.3 JVM启动参数 3.4 环境 ...

  9. maven 利用 profile 进行多环境配置

    我们在进行项目的多环境配置时,有很多种方式供我们选择,比如 SpringBoot 自带的 application-dev.yml.maven 的 profile 等.这里介绍的就是如何利用 profi ...

随机推荐

  1. python里面出现中文的时候报错 'ascii' codec can't encode characters in position

    编码问题,在头部添加 import sys reload(sys) sys.setdefaultencoding( "utf-8" ) http://www.xuebuyuan.c ...

  2. 【转发】揭秘Facebook 的系统架构

    揭底Facebook 的系统架构 www.MyException.Cn   发布于:2012-08-28 12:37:01   浏览:0次 0 揭秘Facebook 的系统架构 www.MyExcep ...

  3. Linux文件操作常用命令整理

    收集.整理日常系统管理或维护当中的,常用到的一些关于文件操作的命令或需求,后续会慢慢补充.完善! 查看.生成指定目录的目录树结构?   [root@DB-Server ~]#tree   #当前目录 ...

  4. maven 安装alipay-sdk包到本地及远程仓库

    安装到本地:mvn install:install-file -DgroupId=com.alipay -DartifactId=sdk-Java -Dversion=*** -Dpackaging= ...

  5. SQL Server:孤立用户详解

    SQL Server 的用户安全管理分两层,整个SQL Server 服务器一层,每个数据库一层. 在服务器层的帐号,叫登录账户(SQL Server:服务器角色),可以设置它管理整个SQL Serv ...

  6. SQL查询数据库中所有指定类型的字段名称和所在的表名

    --查询数据库中所有指定类型的字段名称和所在的表名 --eg: 下面查的是当前数据库中 所有字段类型为 nvarchar(max) 的字段名和表名 SELECT cols.object_id , co ...

  7. 未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项 解决方法

    在webconfig中加入这段话就可以了 <runtime>    <assemblyBinding xmlns="urn:schemas-microsoft-com:as ...

  8. HBase 高性能获取数据(多线程批量式解决办法) + MySQL和HBase性能测试比较

    摘要:   在前篇博客里已经讲述了通过一个自定义 HBase Filter来获取数据的办法,在末尾指出此办法的性能是不能满足应用要求的,很显然对于如此成熟的HBase来说,高性能获取数据应该不是问题. ...

  9. Keil代码中for循环延时问题

  10. sqlite3 shell的使用

    sqlite的安装 1. 首先是下载sqlite,可以该页面下载:http://www.sqlite.org/download.html 当前的最新版本为:sqlite-shell-win32-x86 ...