2019独角兽企业重金招聘Python工程师标准>>>

web.xml:

<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>  <context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:/spring/applicationContext*.xml</param-value></context-param><context-param><param-name>spring.profiles.default</param-name><!-- 研发 <param-value>production</param-value>--><param-value>iie_test</param-value> </context-param><servlet><servlet-name>springMVC</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath*:/spring/spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>springMVC</servlet-name><url-pattern>/</url-pattern></servlet-mapping><filter><filter-name>encodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param><init-param><param-name>forceEncoding</param-name><param-value>true</param-value></init-param></filter><filter-mapping><filter-name>encodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><!-- SiteMesh Web-Page Layout filter --><filter><filter-name>sitemeshFilter</filter-name><filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class></filter><filter-mapping><filter-name>sitemeshFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><session-config><session-timeout>20</session-timeout></session-config>

application.xml:

    <!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 --><context:component-scan base-package="cn.ac.nercis.cloudtv.dal"><context:exclude-filter type="annotation"expression="org.springframework.stereotype.Controller" /><context:exclude-filter type="annotation"expression="org.springframework.web.bind.annotation.ControllerAdvice" /></context:component-scan><!-- 开发库 --><beans profile="production"><bean id="appConfig"class="org.springframework.beans.factory.config.PropertiesFactoryBean"><property name="locations"><list><value>classpath*:/props/prod/*.properties</value></list></property></bean><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"><property name="properties" ref="appConfig" /></bean></beans><!-- 测试库 --><beans profile="iie_test"><bean id="appConfig"class="org.springframework.beans.factory.config.PropertiesFactoryBean"><property name="locations"><list><value>classpath*:/props/iie_test/*.properties</value></list></property></bean><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"><property name="properties" ref="appConfig" /></bean></beans>

spring-mvc:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 自动扫描且只扫描@Controller --><context:component-scan base-package="cn.ac.nercis.cloudtv.dal.controller" use-default-filters="true"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/><context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/></context:component-scan><bean class="com.mangofactory.swagger.configuration.DocumentationConfig" /><context:property-placeholder location="classpath*:/props/iie_test/swagger.properties" /><!-- 开启spring mvc --><mvc:annotation-driven><mvc:message-converters register-defaults="true"><beanclass="org.springframework.http.converter.ByteArrayHttpMessageConverter" /><!-- 将StringHttpMessageConverter的默认编码设为UTF-8 --><bean class="org.springframework.http.converter.StringHttpMessageConverter"><constructor-arg value="UTF-8" /></bean><!-- 将Jackson2HttpMessageConverter的默认格式化输出设为true --><beanclass="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean></mvc:message-converters><mvc:argument-resolvers><beanclass="org.springframework.data.web.PageableHandlerMethodArgumentResolver"></bean><beanclass="org.springframework.data.web.SortHandlerMethodArgumentResolver"></bean></mvc:argument-resolvers></mvc:annotation-driven><bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"><property name="contentNegotiationManager"><bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"><property name="ignoreAcceptHeader" value="true"/><property name="defaultContentType" value="application/json"/><property name="mediaTypes"><map><entry key="html" value="text/html"/><entry key="json" value="application/json"/></map></property></bean></property><property name="defaultViews"><list><bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/></list></property></bean><bean id="jspViewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/pages/" /><property name="suffix" value=".jsp" /></bean><mvc:resources mapping="/static/**" location="/static/"/><!-- 容器默认的DefaultServletHandler处理 所有静态内容与无RequestMapping处理的URL-->    <mvc:default-servlet-handler/></beans>

applicationContex-mongo.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cloud="http://schema.cloudfoundry.org/spring" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd        http://www.springframework.org/schema/data/mongo        http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd        http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd        http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd"><mongo:mongo host="${mongo.host}" port="${mongo.port}"><mongo:options connections-per-host="10"threads-allowed-to-block-for-connection-multiplier="5"connect-timeout="10000"max-wait-time="15000"auto-connect-retry="true"socket-keep-alive="true"socket-timeout="15000"slave-ok="true"write-number="1"write-timeout="0"write-fsync="true"/>
</mongo:mongo><mongo:db-factory dbname="${mongo.database}" mongo-ref="mongo" username="${mongo.username}" password="${mongo.password}"/><mongo:repositories base-package="cn.ac.nercis.cloudtv.dal.repository"/><bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"><constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean><mongo:mapping-converter id="converter" /><bean class="org.springframework.data.mongodb.gridfs.GridFsTemplate"><constructor-arg ref="mongoDbFactory" /><constructor-arg ref="converter" /></bean></beans>

applicationContex-mysql.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jee="http://www.springframework.org/schema/jee"xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd"default-lazy-init="true"><description>Spring数据库配置 </description><!-- transaction manager, use JtaTransactionManager for global tx --><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><!-- enable transaction demarcation with annotations --><tx:annotation-driven /><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="configLocation" value="classpath:mybatis/configuration.xml" /><property name="mapperLocations"><list><value>classpath*:cn/ac/nercis/cloudtv/dal/repository/mapper/*.xml</value></list></property></bean><!-- scan for mappers and let them be autowired --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="cn.ac.nercis.cloudtv.dal.repository.mapper" /><!-- 如果不加下面这行,单独在Tomcat里启动时,Tomcat启动不了 --><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /></bean><!-- 数据源配置, 使用Tomcat JDBC连接池 --><bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"><!-- Connection Info --><property name="driverClassName" value="${jdbc.driver}" /><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /><!-- Connection Pooling Info --><property name="maxActive" value="${jdbc.pool.maxActive}" /><property name="maxIdle" value="${jdbc.pool.maxIdle}" /><property name="minIdle" value="0" /><property name="defaultAutoCommit" value="false" /></bean></beans>

mysql.properties:

mongo.database=pdp
mongo.host=10.10.104.16
mongo.password=
mongo.port=17017
mongo.username=

mongo.properties:

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.10.104.16:3306/cloudtv2?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456#dbcp settings
jdbc.pool.maxIdle=5
jdbc.pool.maxActive=40

转载于:https://my.oschina.net/u/1246433/blog/414361

spring+springMVC+配置文件propertites相关推荐

  1. Spring+SpringMVC +MyBatis整合配置文件案例66666

    Spring+SpringMVC +MyBatis整合配置文件案例 标签: springspringmvcmybatismvcjava 2017-04-13 19:12 228人阅读 评论(1) 收藏 ...

  2. spring和springMVC配置文件中的扫描包如何配置

    我的项目大概文件路径: 然后进入主题: spring的配置文件名称为applicationContext.xml springMVC的配置文件名称为dispatcherServlet-servlet. ...

  3. SSM框架整合(Spring+SpringMVC+MyBatis)

    输出结果 1.Maven Web项目创建 之前有写过Eclipse+Maven创建web项目的帖子,如果需要,请参考这里写链接内容 创建好项目之后因为入下图: 2.SSM整合 2.1 引入需要的JAR ...

  4. Spring+SpringMVC+shiro+mysql(一)

    Spring+SpringMVC+shiro+mysql(一) 最近要做个后台管理系统,就会设计到权限的管理控制,于是就想到 shiro ,下面是自己对Spring+shiro的一点点理解,记录下来, ...

  5. Spring+SpringMVC+Mybatis整合

    一.简单测试工程搭建 1.Mybatis所需要的的jar包(包含数据库驱动包和相关的日志包).SpringMVC和Spring的jar包 2.然后构建一个基本的工程,这里我们使用mapper代理的方式 ...

  6. Spring+SpringMVC+MyBatis深入学习及搭建(十)——MyBatis逆向工程

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6973266.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(九)--My ...

  7. SSM框架整合(IntelliJ IDEA + maven + Spring + SpringMVC + MyBatis)

    使用IDEA创建Spring + SpringMVC + MyBatis 框架的Maven的项目. 一. 创建maven项目 1. File -> New Module,进入创建项目窗口. 2. ...

  8. Spring+SpringMvc+Hibernate 框架搭建

    2019独角兽企业重金招聘Python工程师标准>>> 框架篇:Spring+SpringMVC+hibernate整合开发 一.建立项目 1.新建一个空项目project 相当于e ...

  9. Maven整合SSM框架(maven+spring+springmvc+mybatis)

    啊哈,终于到了用Maven整合SSM这个扑街含家产了.弄了整整一天才跑通.Mybatis的配置有些繁琐,跟之前学习的那个有点出去,加上Eclipse的Spring工具没有弄,配置的时候没有提示被搞蒙圈 ...

最新文章

  1. 自动化录制脚本java_自动化java+webdriver常用的一些脚本
  2. JavaScript设计模式系列四之外观模式(附案例源码)
  3. 幂等性概念及数据库乐观锁机制
  4. 案例代码:sprimngboot备份数据库
  5. 密码学系列之:明文攻击和Bletchley Park
  6. 2019/12/11学习内容摘要(Linux系统用户与用户组管理①)
  7. 未了(endless)(【CCF】NOI Online 能力测试2 入门组第一题 )
  8. 最短路径之迪杰斯特拉算法
  9. ScreenToGif – 免费开源 GIF 录屏制作软件之王!对比多款主流 GIF 工具我选了它
  10. ios github客户端_GitHub推出本地iOS和Android客户端
  11. 动视暴雪消费产品集团首次亮相2018年中国授权展
  12. 大学四年软件工程专业的学习经验总结
  13. 页游游戏市场发展随笔
  14. 怎么拆分PDF文件?分享两种拆分文件的方法
  15. Dfinity(icp)参考命令及规范-7
  16. 不解压压缩包直接解析内部文件(zip)
  17. 漏洞分析---SSLv3降级加密协议Padding Oracle攻击(POODLE)技术分析
  18. python快递费用计算_Python实现快递查询
  19. 签名设计一笔教写过程
  20. 数字化助力生产制造管理:专项生产管理系统

热门文章

  1. 电气器件系列十五:CBB电容
  2. 循迹小车计数显示模块设计
  3. 领悟这148句话,你可以提高一个档次了,一起分享,希望您能开心每一天~
  4. 向前(向上)、向后(向下)兼容
  5. 计算机网络第七版第一章阅读
  6. JavaFx - Button长按事件
  7. 小红伞居然流氓了一把
  8. docker 详细介绍安装步骤以及简单的运用
  9. day10string
  10. dts 编译过程_DTS结构及其编译方法