博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring.profile配合Jenkins发布War包,实现开发、测试和生产环境的按需切换
阅读量:4597 次
发布时间:2019-06-09

本文共 4246 字,大约阅读时间需要 14 分钟。

前两篇不错

Spring.profile实现开发、测试和生产环境的配置和切换 - Strugglion - 博客园

https://www.cnblogs.com/strugglion/p/7091021.html

详解Spring中的Profile - 简书

https://www.jianshu.com/p/948c303b2253

spring-mvc-hibernate.xml

 

web.xml

spring.profiles.default
dev

 setenv.sh

[root@crm_web apache-tomcat-7.0.91]# cat bin/setenv.shCATALINA_OPTS="$CATALINA_OPTS -Dspring.profiles.active=test -Djava.rmi.server.hostname=192.168.66.16 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access"

 setenv.bat

set CATALINA_OPTS=-Dspring.profiles.active=test -Djava.rmi.server.hostname=192.168.66.182 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access

 

 

注意事项:

1.spring.profiles.active

2.profile 特性是在spring3.1中引入的,3.0还不支持。xml配置中的spring-beans-3.0.xsd,在3.0中解析不到3.1中的profile,所以必须替换成spring-beans-3.1.xsd

  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

  http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

3.Nested <beans> must appear last in the file.

  https://dzone.com/articles/spring-31-environment-profiles

    Nested <beans> must appear last in the file.

    文件有正确顺序的标签示例。

  https://stackoverflow.com/questions/33869324/spring-profile-and-property-placeholder-exception

    I would try to re-order the application context file, having the two profiles before <context:property-placeholder properties-ref="deployProperties" />.

  http://www.cnblogs.com/davidwang456/p/4204569.html

   // Any nested 
elements will cause recursion in this method. In // order to propagate and preserve
default-* attributes correctly, // keep track of the current (parent) delegate, which may be null. Create // the new (child) delegate with a reference to the parent for fallback purposes, // then ultimately reset this.delegate back to its original (parent) reference. // this behavior emulates a stack of delegates without actually necessitating one.    还得多读源码,如果不把
放在
,会导致循环引用的问题。

官方参考

3. New Features and Enhancements in Spring Framework 3.1

https://docs.spring.io/spring-framework/docs/3.2.0.RELEASE/spring-framework-reference/html/new-in-3.1.html

Spring 3.1 M2: Testing with @Configuration Classes and Profiles

http://spring.io/blog/2011/06/21/spring-3-1-m2-testing-with-configuration-classes-and-profiles/

Spring 3.1 M1: Introducing @Profile

http://spring.io/blog/2011/02/14/spring-3-1-m1-introducing-profile/

Spring Framework 3.1 M1 released

http://spring.io/blog/2011/02/11/spring-framework-3-1-m1-released/

11. Testing

https://docs.spring.io/spring-framework/docs/3.2.0.RELEASE/spring-framework-reference/html/testing.html#testcontext-framework

cbeams/spring-3.1-profiles-java: Sample demonstrating use of Spring 3.1's 'bean definition profiles' feature with @Configuration classes

https://github.com/cbeams/spring-3.1-profiles-java

Spring Framework Reference Documentation

http://files.cnblogs.com/files/kongkaikai/spring-framework-reference.pdf

Introduction · Spring Framework 4.x参考文档

http://blog.didispace.com/books/spring-framework-4-reference/

 

 

以下的作为参考

Spring实战——Profile - JackieZheng - 博客园

http://www.cnblogs.com/bigdataZJ/p/SpringInAction4.html

通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换 - 许恕 - CSDN博客

https://blog.csdn.net/xvshu/article/details/51133786

详解Spring中的Profile - 王云十三 - 博客园

https://www.cnblogs.com/SummerinShire/p/6392242.html

详解Spring中的Profile - 刘剑峰的博客 - CSDN博客

https://blog.csdn.net/jeffleo/article/details/71433655

spring @profile注解的使用 - 止水的专栏 - CSDN博客

https://blog.csdn.net/wild46cat/article/details/71189858

转载于:https://www.cnblogs.com/rgqancy/p/9895316.html

你可能感兴趣的文章
实习网申小技巧
查看>>
JS认证Exchange
查看>>
php面试题之一——HTML+CSS(基础部分)
查看>>
用MATLAB怎么实现曲线拟合?
查看>>
react-native组件封装与传值
查看>>
Xml
查看>>
后台管理界面
查看>>
无线话筒U段和V段有哪些本质区别?
查看>>
Delphi判断文件是否正在被使用
查看>>
AutoCAD(英文版)中所有英语词汇的翻译
查看>>
powerdesigner添加mysql的字符集ENGINE和DEFAULT CHARACTER SET
查看>>
在.net中使用WebBrowser
查看>>
委托和事件
查看>>
x名称空间详解
查看>>
xamarin.android 消息推送功能--极光推送
查看>>
词向量的cbow模型
查看>>
UDP简单例子
查看>>
viewpager viewpager+fragment
查看>>
第二次冲刺
查看>>
使用JavaScriptSerializer序列化集合、字典、数组、DataTable为JSON字符串 ...
查看>>