java工程中spring.xml配置
2014-02-22 11:39
316 查看
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 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-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <context:annotation-config/> <context:component-scan base-package="hing.spring"></context:component-scan> <!-- 引入属性文件 --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:hing/spring/property/jdbc.properties</value> </property> </bean> <!-- 配置数据源 --> <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${driverClassName}"/> <property name="url" value="${url}"/> <property name="username" value="${username}"/> <property name="password" value="${password}"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>hing.spring.model</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <!-- 定义事务管理器(声明式的事务) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="interceptorPointCuts" expression="execution(* hing.spring.serivce..*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" /> </aop:config> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <aop:aspectj-autoproxy/> <!-- <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator" /> --> </beans>
相关文章推荐
- 【spring in action 学习--springMVC搭建】在不使用web.xml的情况下,配置Srping MVC工程
- Spring基础篇——通过Java注解和XML配置装配bean
- 【Bug解决】Spring配置错误:java.io.FileNotFoundException: class path resource [cxd/entity/User.hbm.xml] canno
- spring AOP 之 xml 配置实现(附 Java 代码实例)
- Java开发框架--spring-servlet.xml 配置详解
- Spring的Java配置方式(无xml)
- Java开发框架--spring-myBatis.xml 配置详解
- JavaWeb工程中web.xml基本配置
- Spring学习----------Bean配置的三种方式(XML、注解、Java类)介绍与对比
- java实现Spring在XML配置java类
- JavaWeb工程中web.xml基本配置
- spring中xml的javabean的配置
- Spring 总结XML配置的十二个最佳实践-Java基础-Java-编程开发
- Spring基础篇——通过Java注解和XML配置装配bean
- javaWeb工程中web.xml的基本配置
- Spring实战——XML和JavaConfig的混合配置
- java中spring+springMVC+Mybatis主流框架maven的pom.xml配置参考
- Spring 基于XML配置 基于注解配置 基于JAVA类配置比较以及适用场景
- java创建的web工程中web.xml配置说明
- Spring实战——XML和JavaConfig的混合配置