首页 测试 体会 查看内容

项目开发中切换部署开发、测试、生产多环境

2014-6-25 14:33| 发布者: tianzc| 查看: 555| 评论: 0

摘要:   在开发的过程中,不可避免会接触到至少三个环境的程序部署:开发、测试和生产环境。  每个环境都使用一套数据库配置,路径配置等,如果每次都人工的干预每一个配置文件,工作会比较繁杂,且容易遗漏并且出错。 ...
  此处定义了不同环境下不同的数据库链接信息  3、web.xml中定义当前使用哪个环境  在web.xml中操作context-param节点  <context-param>  <param-name>spring.profiles.active</param-name>  <param-value>product</param-value>  </context-param>  部署时指定哪个环境为激活状态即可。  如果进行junit测试可以使用  @ActiveProfiles({"test","develop"})  附: 如果spring的profile可以和maven的发布共同作用就更好了,但是笔者目前还未能成功将2者结合。  配置提醒:  <beans xmlns="http://www.springframework.org/schema/beans" profile="test,develop" -----设置这个之后,数据库只对test,develop有效  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">  <!-- 定义数据连接池 -->  <!-- 使用spring自带的DriverManagerDataSource方式 -->
12

鲜花

握手

雷人

路过

鸡蛋

扫一扫关注最新动态

毒镜头:老镜头、摄影器材资料库、老镜头样片、摄影
爱评测 aipingce.com  
返回顶部