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 閱讀(4528) 評論(0)  編輯  收藏 所屬分類: MAVENTOMCAT

          主站蜘蛛池模板: 英超| 凤台县| 灌阳县| 鱼台县| 阜南县| 金湖县| 宜都市| 鞍山市| 台东市| 辽阳县| 左权县| 昭通市| 水富县| 晴隆县| 彭阳县| 格尔木市| 吴旗县| 潞西市| 始兴县| 九江市| 涞源县| 柯坪县| 昌都县| 铜陵市| 综艺| 涪陵区| 阜宁县| 若尔盖县| 林甸县| 晋宁县| 汤阴县| 清原| 嵊州市| 高台县| 宝兴县| 莎车县| 集安市| 新昌县| 江山市| 喀喇沁旗| 明光市|