Spring完整配置文件带注释(自动扫包)
2013-12-24 13:15
316 查看
<?xml version="1.0" encoding="UTF-8"?> <beans default-autowire="byName" default-lazy-init="true" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 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/aop http://www.springframework.org/schema/aop/spring-aop-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 "> <!-- 开启注解配置 --> <context:annotation-config /> <!-- 对指定的包进行组件扫描 --> <context:component-scan base-package="com.lun" /> <!--链接数据库 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property> <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"></property> <property name="username" value="lun"></property> <property name="password" value="123"></property> </bean> <!-- 配置hibernate的sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="hibernateProperties"> <props> <!-- 数据库方言 --> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop> <!-- 在控制台打印执行的sql语句 --> <prop key="hibernate.show_sql">true</prop> </props> </property> <!-- 加载所有的实体配置文件 --> <property name="mappingDirectoryLocations"> <list> <value>classpath:com/lun/entity</value> </list> </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="get*" read-only="true" propagation="NOT_SUPPORTED" /> <tx:method name="find*" read-only="true" propagation="NOT_SUPPORTED" /> <tx:method name="select*" read-only="true" propagation="NOT_SUPPORTED" /> <tx:method name="save*" rollback-for="Exception" propagation="REQUIRED" /> <tx:method name="add*" rollback-for="Exception" propagation="REQUIRED" /> <tx:method name="update*" rollback-for="Exception" propagation="REQUIRED" /> <tx:method name="del*" rollback-for="Exception" propagation="REQUIRED" /> <tx:method name="*" rollback-for="Exception" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- 事务切面配置 --> <aop:config> <aop:pointcut expression="execution(* com.lun.biz.*.*(..))" id="transactionPointcut" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut" /> </aop:config> <!-- 注入jdbcTemplate --> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <constructor-arg ref="dataSource"/> </bean> <!-- 注入hibernateTemplate --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory" /> </bean> </beans>
相关文章推荐
- Spring完整配置文件带注释(自动扫包)
- 在weblogic下部署web应用,加载spring配置文件时要删除注释
- spring mvc 在Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别
- spring多文件配置,非单例手工注入,单例自动注入
- spring完整配置文件
- ssh框架中spring整合hibernate的配置文件模板(带详细注释)
- spring完整配置文件(applicationContext.xml)
- Struts2完整配置文件带注释(开发项目期间最实用)
- Spring配置文件里面自动提示配置方法
- r.js 配置文件 example.build.js 不完整注释
- Spring 依赖注入:自动注入properties文件中的配置
- Spring配置文件自动提示导入法
- eclipse(xmlbuddy插件)为xml文件自动提示(同MyEclipse编辑XML的提示功能),以spring配置文件为例
- MyEclipse添加xml文件自动提示方法,以spring配置文件为例
- spring mvc 在Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别
- [C] c99int(让VC等编译器自动兼容C99的整数类型)V1.02。源码托管到github、添加CMake编译配置文件、使用doxygen规范注释
- 在Web.xml中自动扫描Spring的配置文件及resource时classpath*:与classpath:的区别
- 扩展:Spring的PropertyPlaceholderConfigurer应用(自动获取配置文件的数据)
- [原创]java WEB学习笔记99:Spring学习---Spring Bean配置:自动装配,配置bean之间的关系(继承/依赖),bean的作用域(singleton,prototype,web环境作用域),使用外部属性文件
- spring配置mybatis自动扫描*mapper.java和*mapper.xml配置文件