`
玉德思密达
  • 浏览: 7561 次
社区版块
存档分类
最新评论

Spring Mvc模块化配置思考

阅读更多

applicationContext.xml(spring 基础配置文件放在spring包下,web.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:aop="http://www.springframework.org/schema/aop
       xmlns:tx="http://www.springframework.org/schema/tx
    xmlns:context="http://www.springframework.org/schema/context
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
    http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-3.0.xsd 
       http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> 

<!-- auto register Processor -->
<context:annotation-config/>

<bean id="propertyConfigurer"
  class="com.xxx.common.config.GlobalConfigPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/META-INF/spring/jdbc.properties</value>
<value>classpath:/META-INF/spring/common-mis.properties</value>
<value>classpath:/META-INF/spring/config.properties</value>
<value>classpath:/META-INF/spring/cognos.properties</value>
<value>classpath:/META-INF/spring/client.properties</value>
</list>
</property>
</bean>

<import resource="classpath:META-INF/spring/persistence-ceo.xml"/>
<import resource="classpath:META-INF/spring/dal-dao-ceo.xml"/><!--导入配置文件 dao层依赖注入--->
<import resource="classpath:META-INF/spring/dal-dao-ceo-batch.xml"/>
<import resource="classpath:META-INF/spring/cache-context-mis.xml"/>

<import resource="classpath:META-INF/spring/services-ceo.xml"/>

<!-- system manager start -->
<import resource="classpath:META-INF/spring/persistence-system.xml"/>
<import resource="classpath:META-INF/spring/dal-dao-system.xml"/>
<import resource="classpath:META-INF/spring/dal-dao-system-batch.xml"/>
<import resource="classpath:META-INF/spring/services-system.xml"/>
<!-- system manager end -->

<!-- engine start -->
<!--
<import resource="classpath:META-INF/spring/persistence-engine-test.xml"/>
<import resource="classpath:META-INF/spring/dal-dao-engine.xml"/>
<import resource="classpath:/META-INF/spring/common-core-engine.xml"/>
<import resource="classpath:/META-INF/spring/common-core-lock.xml"/>
<import resource="classpath:/META-INF/spring/common-core-schedule.xml"/>-->
<!-- engine end -->

<!-- security -->
<import resource="classpath:META-INF/spring/spring-security.xml"/>
<!-- <import resource="classpath:META-INF/spring/spring-pre-security.xml"/>-->
    <!-- remote -->
 <import resource="classpath:META-INF/spring/remote-client.xml"/>
</beans>
 

persistence-ceo.xml(spring包下,由applicationContext.xml文件import,顾名思义,本配置文件一般无需修改)

<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation=" http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

 <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName">
   <value>${jdbc.driverClassName}</value>
  </property>
  <property name="url">
   <value>${jdbc.url}</value>
  </property>
  <property name="username">
   <value>${jdbc.username}</value>
  </property>
  <property name="password">
   <value>${jdbc.password}</value>
  </property>
 
  <property name="maxWait" value="300000"/>
  <property name="maxIdle" value="30"/>
  <property name="maxActive" value="100"/>
  <property name="testOnBorrow" value="true"/>
  <property name="testWhileIdle" value="true"/>
     <property name="validationQuery" value="select 1 from dual"/>
  
 </bean>
 
 <bean id="sqlMapClient" class="com.xxx.core.ibatis.IncludesSqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sqlmap/sqlmap-ceo.xml"/>
 </bean>

 <bean id="misCeoSqlMapClientDAO" abstract="true">
  <property name="sqlMapClient" ref="sqlMapClient"/>
  <property name="dataSource" ref="dataSource"/>
 </bean>
 
 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  <property name="dataSource" ref="dataSource"></property>
 </bean>
 
 <bean id="commonJdbcDao" class="com.xxx..core.dal.daointerface.CommonJDBCDAO">
  <property name="jdbcTemplate" ref="jdbcTemplate"></property>
 </bean>
 
 <bean id="misJxBaoBiaoDAO" abstract="true">
  
  <property name="dataSource" ref="dataSource"/>
 </bean>

 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource"/>
 </bean>
 
 <tx:annotation-driven transaction-manager="transactionManager"/>
 
 <bean id="threadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
  <property name="corePoolSize" value="16"/>
  <property name="maxPoolSize" value="200"/>
  <property name="queueCapacity" value="500"/>
 </bean>

</beans>

 

dal-dao-ceo.xml(spring包下)

  <?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:osgi="http://www.springframework.org/schema/osgi"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"
 default-autowire="byName">
    <!-- ======================================================================== -->
    <!--  DAO                                                            -->
    <!-- ======================================================================== -->
 <bean id="misSeqDAO" class="com.xxx.core.dal.ibatis.IbatisSeqDAO" parent="misCeoSqlMapClientDAO"/>

<!--misCeoSqlMapClientDAO是在application中配置的抽象bean,其中定义了sqlMapClient和dataSource

      如此 便可以连接数据库和操作数据库了-->
     
    <bean id="alertConfigDAO" class="com.xxx.core.dal.ibatis.IbatisAlertConfigDAO" parent="misCeoSqlMapClientDAO"/>

</bean>
   

分享到:
评论

相关推荐

    [免费]Spring MVC学习指南(高清)

    Spring MVC是Spring框架中用于Web应用快速开发的一个模块,其中的MVC是Model-View-Controller的缩写。作为当今业界最主流的Web开发框架,Spring MVC已经成为当前最热门的开发技能,同时也广泛用于桌面开发领域。 ...

    大优惠 Spring MVC学习指南(第2版)2017.pdf

    Spring MVC是Spring框架中用于Web应用快速开发的一个模块,其中的MVC是Model-View-Controller的缩写。作为当今业界最主流的Web开发框架,Spring MVC已经成为当前最热门的开发技能,同时也广泛用于桌面开发领域。 ...

    Spring MVC学习指南

    Spring MVC是Spring框架中用于Web应用快速开发的一个模块,其中的MVC是Model-View-Controller的缩写。作为当今业界最主流的Web开发框架,Spring MVC已经成为当前最热门的开发技能,同时也广泛用于桌面开发领域。, ...

    Spring.MVC-A.Tutorial-Spring.MVC学习指南

    Spring MVC是Spring框架中用于Web应用快速开发的一个模块,其中的MVC是Model-View-Controller的缩写。作为当今业界主流的Web开发框架,Spring MVC已经成为当前热门的开发技能,同时也广泛用于桌面开发领域。  ...

    基于Spring + Spring MVC + Mybatis

    快速搭建项目原型,基于Spring + Spring MVC + Mybatis,简单轻便、易于扩展的架构,适用于大多数项目 ...大量前端模块化开发示例,积极在探索前端最佳的架构,与后台最佳的交互,构建雄心勃勃的Application

    Spring MVC学习指南 第2版 高清版

    Spring MVC是Spring框架中用于Web应用快速开发的一个模块,其中的MVC是Model-View-Controller的缩写。作为当今业界最主流的Web开发框架,Spring MVC已经成为当前最热门的开发技能,同时也广泛用于桌面开发领域。 ...

    Spring.MVC-A.Tutorial-Spring.MVC学习指南.rar

    Spring MVC是Spring框架中用于Web应用快速开发的一个模块,其中的MVC是Model-View-Controller的缩写。作为当今业界最主流的Web开发框架,Spring MVC已经成为当前最热门的开发技能,同时也广泛用于桌面开发领域。 ...

    Spring+MVC+Mybatis 书城项目

    Spring MVC: Spring MVC是Spring框架的一个模块,它实现了MVC(模型-视图-控制器)设计模式,用于构建Web应用。Spring MVC允许你将应用的逻辑、数据和用户界面分离,使得代码更加清晰和易于维护。 MyBatis: MyBatis...

    Spring mvc +ext 4mvc 颗粒模块化设计简单的CRUD

    近年最新的工程开发实例 源码档放进eclipse编译一下就能运行了

    Spring中MVC模块代码详解

    主要介绍了Spring中MVC模块代码详解,涉及Controller的简单介绍,具有一定借鉴价值,需要的朋友可以参考下。

    构建MetroNic+Mybatis+ Spring MVC的高性能web应用

    以及Web前端模块化、组件化开发,与后台最佳的交互;以及探索使用NoSQL、与SQL等多数据库共存的解决方案; 提供大量模块参考,比如:权限管理模块。前端使用MetroNic模板,后端架构:Spring + Spring MVC + Mybatis ...

    基于spring freemarker jdbctemplate jquery的一个完整的项目例子

    初次学习spring。才看了《spring 3.x》第一章内容,写的一个例子;...使用技术细节:spring mvc 模块化设计;freemarker视图层;jdbctemplate访问数据库;log4j配置文件;json拼凑; jquery技术;分库分表访问的设计;

    Spring攻略PDF版

     2.1.1 Spring的模块介绍   2.1.2 Spring的发布版本   2.1.3 Spring的项目   2.2 安装Spring Framework   2.2.1 问题描述   2.2.2 解决方案   2.2.3 实现方法   2.3 建立Spring项目 ...

    Spring攻略中文版PDF

     2.1.1 Spring的模块介绍   2.1.2 Spring的发布版本   2.1.3 Spring的项目   2.2 安装Spring Framework   2.2.1 问题描述   2.2.2 解决方案   2.2.3 实现方法   2.3 建立Spring项目 ...

    spring4.3.2参考文档(英文)

    Spring AOP:通过配置管理特性,Spring AOP 模块直接将面向方面的编程功能集成到了 Spring 框架中。所以,可以很容易地使 Spring 框架管理的任何对象支持 AOP。Spring AOP 模块为基于 Spring 的应用程序中的对象提供...

    Spring攻略英文版(附带源码)

     2.1.1 Spring的模块介绍   2.1.2 Spring的发布版本   2.1.3 Spring的项目   2.2 安装Spring Framework   2.2.1 问题描述   2.2.2 解决方案   2.2.3 实现方法   2.3 建立Spring项目   ...

    毕业设计管理系统java服务端,采用spring mvc.zip

    这使得Java编写的代码更加模块化、可维护和可扩展。 多线程支持: Java内置了对多线程的支持,允许程序同时执行多个任务。这对于开发需要高并发性能的应用程序(如服务器端应用、网络应用等)非常重要。

    图书管理系统( Spring+Spring MVC+JdbcTemplate).zip

    这使得Java编写的代码更加模块化、可维护和可扩展。 多线程支持: Java内置了对多线程的支持,允许程序同时执行多个任务。这对于开发需要高并发性能的应用程序(如服务器端应用、网络应用等)非常重要。 自动内存...

Global site tag (gtag.js) - Google Analytics