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

发表于:2014-6-12 11:01

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:xingxingxing    来源:51Testing软件测试网采编

  此处定义了不同环境下不同的数据库链接信息
  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方式 -->
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号