<?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"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-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/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/mysqlDB" />
<context:component-scan base-package="com.xxx" />
<!-- 支持aop注解 -->
<aop:aspectj-autoproxy />
<import resource="quartzConfig*.xml" />
<!--
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/myhib"></property>
<property name="username" value="root"></property>
<property name="password" value="123"></property>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" destroy-method="close">
<property name="jndiName">
<value>
java:comp/env/jdbc/mysqlDB
</value>
</property>
</bean>
-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<!--
org.hibernate.dialect.DB2Dialect
org.hibernate.dialect.MySQLDialect
org.hibernate.dialect.PostgreSQLDialect
-->
<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect </prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.show_sql">false</prop>
<!-- 缓存策略,数据量不大可不写 -->
<prop key="cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="cache.use_query_cache">false</prop>
<prop key="cache.use_second_level_cache">false</prop>
<prop key="hibernate.jdbc.fetch_size">1</prop>
<prop key="hibernate.jdbc.batch_size">5</prop>
<prop key="hibernate.fetch">true</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</prop>
</props>
</property>
<property name="packagesToScan">
<value>com.xxx.pojo</value>
</property>
</bean>
<!--hibernateTemplate -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 配置事务管理 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" ></property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<!-- AOP的配置 -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut expression="execution(public * com.xxx.service.*.*.*(..))" id="businessService" />
<!-- 通知 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="businessService" />
</aop:config>
<!-- 具体的通知 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<!-- <tx:method name="find*" read-only="true" propagation="NOT_SUPPORTED" />-->
<tx:method name="find*" read-only="false" propagation="NOT_SUPPORTED" />
<!-- get开头的方法不需要在事务中运行 。
有些情况是没有必要使用事务的,比如获取数据。
开启事务本身对性能是有一定的影响的
-->
<tx:method name="*" /> <!-- 其他方法在实务中运行 -->
</tx:attributes>
</tx:advice>
</beans>
分享到:
相关推荐
application.xml配置文件详解 application.xml配置文件详解 application.xml配置文件详解
<?xml version="1.0" encoding="UTF-8"?> <!-- - Application context definition for JPetStore's business ... (* com.longxian.drp.manager.*.*(..))" advice-ref="txAdvice"/> </aop:config> </beans>
application-service.xml
J2EE deployment files (application.xml)
application.properties配置: #mybatis mybatis.config-location=classpath:mybatis-config.xml mybatis.check-config-location=true mybatis.mapper-locations=classpath:mappers/*.xml
J2EE 配置文件(application-client.xml) (英文)
activiti.cfg.xml和application.properties文件的整合配置,不能两个都存在,方便,适应
这是一些配置文件,可以作为参考,个人感觉很方便的学习方法
*.支持读写分离,分库分表,读数据源熔断,数据源运行监控 *.支持JPA,既有hibernate的便捷操作,又有mybatis的sql集中编写or管理的风格;支持乐观锁 *.支持防缓存穿透,防缓存击穿,防缓存雪崩 *.支持多层次缓存:...
Log4j2学习笔记,引入log4j2的依赖-log4j2.xml配置模板-application.properties文件配置-使用
初次使用ssm框架的朋友可以看一下,希望对你有所帮助
struts1 web.xml struts1配置
application-context.xml
包含applicationContext.xml、db.properties、log4j.properties、spring-mvc.xml文件,方便搭建,省去写代码。。
spring+jpa的applicationContext.xml配置
Spring项目application.xml配置文件加解密
一、关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件。它位于整个项目的根目录,描述了package中暴露的组件(activities, services, 等等),他们各自的实现类,各种能被处理的数据和...
applicationContext.xml详解
打开dreamweaver时,提示文件 Designer.xml的工作区不能打开。 出现这样的问题,大家可以去网上下载一个 Designer.xml 文件,然后去 “C:\Documents and Settings\Administrator\Application Data\Adobe\Dreamweaver...