<?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:c= "http://www.springframework.org/schema/c" xmlns:cache= "Http://www.springframework.org/schema/cache"
xmlns:context= "Http://www.springframework.org/schema/context"
Xmlns:jdbc= "Http://www.springframework.org/schema/jdbc" xmlns:jee= "Http://www.springframework.org/schema/jee"
xmlns:lang= "Http://www.springframework.org/schema/lang" xmlns:mvc= "Http://www.springframework.org/schema/mvc"
xmlns:p= "http://www.springframework.org/schema/p" xmlns:task= "Http://www.springframework.org/schema/task"
xmlns:tx= "Http://www.springframework.org/schema/tx" xmlns:util= "Http://www.springframework.org/schema/util"
xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans.xsd
HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP http://www.springframework.org/schema/aop/spring-aop.xsd
Http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
Http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
Http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
Http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
Http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
Http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
Http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd ">
function One:<!-- load external properties profile -- with database
<!--maven can't do this in this way, only in the second way--
<!--<context:property-placeholder location= "Classpath:jdbc.properties"
/>--
<bean
class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name= "Locations" >
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<!-- automatically scan and assemble beans --
<context:component-scan base-package= "*.*.*"/>
<bean id= "DataSource" class= "Com.alibaba.druid.pool.DruidDataSource"
Init-method= "Init" destroy-method= "Close" >
<!-- Basic property URL,user,password --
<property name= "url" value= "${*}"/>
<property name= "username" value= "${username}"/>
<property name= "Password" value= "${password}"/>
<!-- configuration initialization size, MIN, max --
<property name= "InitialSize" value= "1"/>
<property name= "Minidle" value= "1"/>
<property name= "maxactive" value= "/>"
<!-- configuration Gets the time that the connection waits timeout--
<property name= "maxwait" value= "60000"/>
< how long!--configuration interval to detect idle connections that need to be closed, in milliseconds-and
<property name= "Timebetweenevictionrunsmillis" value= "60000"/>
<!-- Configure the minimum time for a connection to survive in a pool, in milliseconds- -
<property name= "Minevictableidletimemillis" value= "300000"/>
<property name= "Validationquery" value= "select ' X '"/>
<property name= "Testwhileidle" value= "true"/>
<property name= "Testonborrow" value= "false"/>
<property name= "Testonreturn" value= "false"/>
<!-- Open pscacheand specify the size of pscache on each connection -
<property name= "Poolpreparedstatements" value= "true"/>
<property name= "Maxpoolpreparedstatementperconnectionsize"
Value= "/>"
<!-- Configuration monitoring Statistics intercept filters--
<property name= "Filters" value= "Mergestat"/>
</bean>
<!-- configuring Druid monitoring Spring JDBC ---
<bean id= "Druid-stat-interceptor"
class= "Com.alibaba.druid.support.spring.stat.DruidStatInterceptor"/>
<bean id= "Druid-stat-pointcut" class= "Org.springframework.aop.support.JdkRegexpMethodPointcut"
Scope= "Prototype" >
<property name= "Patterns" >
<list>
<value>org.bigdatacn.sfgk.wlzbs.service.*</value>
</list>
</property>
</bean>
<aop:config>
<aop:advisor advice-ref= "Druid-stat-interceptor"
pointcut-ref= "Druid-stat-pointcut"/>
</aop:config>
role Two:<!-- open spring cache --
<cache:annotation-driven cache-manager= "CacheManager"/>
<bean id= "Cachemanagerfactory"
Class= "Org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configlocation= "Classpath:ehcache.xml" p:shared= "false"/>
<bean id= "CacheManager" class= "Org.springframework.cache.ehcache.EhCacheCacheManager"
p:cachemanager-ref= "Cachemanagerfactory"/>
role three: performance optimization
<!-- monitoring The execution of DAO and service
<bean id= "Facademonitoringadvisor" class= "Net.bull.javamelody.MonitoringSpringAdvisor" >
<property name= "Pointcut" >
<bean class= "Org.springframework.aop.support.JdkRegexpMethodPointcut" >
<property name= "Patterns" >
<array>
<value>org\.bigdatacn\.sfgk\.wlzbs\.dao\. *</value>
<value>org\.bigdatacn\.sfgk\.wlzbs\.daoimpl\. *</value>
<value>org\.bigdatacn\.sfgk\.wlzbs\.service\. *</value>
<value>org\.bigdatacn\.sfgk\.wlzbs\.view\.service\. *</value>
<value>org\.bigdatacn\.sfgk\.wlzbs\.view\.serviceimpl\. *</value>
</array>
</property>
</bean>
</property>
</bean>
function Four:<!-- configuration sessionfactory----Import hibranate.cfg.xlm
<bean id= "Sessionfactory"
class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "DataSource" ref= "DataSource" ></property>
<property name= "configlocation" value= "Classpath:hibernate.cfg.xml" ></property>
</bean>
role Five: <!-- Configure declarative Transaction management (in an annotation-based manner) --
<bean id= "TransactionManager"
class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>
</bean>
<tx:annotation-driven transaction-manager= "TransactionManager"/>
</beans>
Applicationcontext.xml each role