paulwong

SPRING中多开发+测试多环境中的资源文件配置

property文件有几份,如
mongo_dev.properties
#intranet
mongo.replicationset=10.120.141.229:27017,10.120.141.226:27017,10.120.141.228:27017
mongo.username=cms
mongo.password=cms

mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true

mongo.debug=true
mongo.trace=true


mongo_test.properties
#internet
mongo.replicationset=10.120.11.221:27017,10.120.11.122:27017,10.120.11.212:27017
mongo.username=cms
mongo.password=cms

mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true

mongo.debug=false
mongo.trace=false

Spring的配置文件中加入
<context:property-placeholder
        
location="classpath*:/properties/mongodb/mongo_${spring.profiles.active}.properties />



#将下面参数放在JVM中,如果是TOMCAT则放在catalina.sh
#开发:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev "

#测试:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=test "

#如果是ECLIPSE中启动TOMCAT,则只需加
-Dspring.profiles.active=dev





posted on 2014-03-28 10:57 paulwong 阅读(4354) 评论(0)  编辑  收藏 所属分类: MAVENTOMCAT


只有注册用户登录后才能发表评论。


网站导航: