激活 profile
spring 为我们提供了大量的激活 profile 的方法,可以通过代码来激活,也可以通过系统环境变量、JVM参数、servlet上下文参数来定义 spring.profiles.active 参数激活 profile,这里我们通过定义 JVM 参数实现。
1、ENV方式:
ConfigurableEnvironment.setActiveProfiles("test")
2、JVM参数方式:
tomcat 中 catalina.bat(.sh中不用“set”) 添加JAVA_OPS。通过设置active选择不同配置文件
set JAVA_OPTS="-Dspring.profiles.active=test"
eclipse 中启动tomcat。项目右键 run as –> run configuration–>Arguments–> VM arguments中添加。local配置文件不必上传git追踪管理
-Dspring.profiles.active="local"
- 1
3、web.xml方式:
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>production</param-value>
</init-param>
4、标注方式(junit单元测试非常实用):
@ActiveProfiles({"unittest","productprofile"})
相关推荐
spring事务管理几种方式代码实例:涉及编程式事务,声明式事务之拦截器代理方式、AOP切面通知方式、AspectJ注解方式,通过不同方式实例代码展现,总结spring事务管理的一般规律,从宏观上加深理解spring事务管理特性...
主要给大家介绍了关于spring boot中几种注入方法的一些个人看法,文中通过示例代码介绍的非常详细,对大家学习或者使用spring boot具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
NULL 博文链接:https://shmilyaw-hotmail-com.iteye.com/blog/2169569
bean加入spring容器管理的方式,bean加入applicationcontext容器的方式
本文介绍spring事务传播的几种方式
spring依赖注入的几种方式
NULL 博文链接:https://gary0416.iteye.com/blog/890689
Spring MVC 中几种获取request和response的方式,讲解详细实用!
struts和spring整合的2种方式
Spring事务管理4种方式 入门级 最简单demo PlatformTransactionManager TransactionTemplate
Spring 三种依赖注入方式.doc Spring 三种依赖注入方式.doc
spring配置事务五种方式 代初学都参考使用
Spring下配置几种常用连接池。
spring整合quartz两种方式以及spring自带定时任务使用
Spring配置文件中关于事务配置总是由三个组成部分,分别是DataSource、TransactionManager和代理机制这三部分,无论哪种配置方式,一般变化的只是代理机制这部分。 DataSource、TransactionManager这两部分只是会...
里面包含了多种Spring AOP配置,十分详细。
spring几种事务配置,spring几种事务配置详解【精】
spring整合数据库连接的方式 dbcp c3p0 proxool
创建Spring boot的三种方式
spring 依赖注入三种方式测试源码,测试细节参考博文http://blog.csdn.net/u010679383/article/details/71305400