applicationContext.xml文件配置

applicationContext.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:jee="http://www.springframework.org/schema/jee"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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/jee http://www.springframework.org/schema/jee/spring-jee-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"
	default-autowire="byName" default-lazy-init="true">

	<!-- 建立数据源 -->
	<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="driver" value="oracle.jdbc.driver.OracleDriver"></property>
		<property name="driverUrl" value="jdbc:oracle:thin:@10.1.100.10:1521:testerp"></property>
		<property name="user" value="ecommerce"></property>
		<property name="password" value="ecommerce"></property>
		<property name="minimumConnectionCount" value="10"></property>
		<property name="maximumConnectionCount" value="100"></property>
	</bean>
	<!-- sessionFactory配置 -->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<!-- 实体映射文件夹 -->
		<!-- <property name="mappingDirectoryLocations">
			<list>
				<value>classpath:com/testdl/demo/model/maps</value>
			</list>
		</property> -->
		<!-- 实体映射文件-->
		<property name="mappingResources">
			<list>
				<value>test/testEntity/Puser.hbm.xml</value>
				<value>test/testEntity/PuserFavorite.hbm.xml</value>
			</list>
		</property>
		<!-- 数据库属性配置 -->
		<property name="hibernateProperties">
			<props>
				<!-- SQL方言 -->
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
				<!-- 为true表示将Hibernate发送给数据库的sql显示出来 -->
				<prop key="hibernate.show_sql">true</prop>
				<!-- 格式化输出sql语句 -->
				<prop key="hibernate.format_sql">true</prop>
				<!-- 收集有助于性能调节的统计数据 -->
				<prop key="hibernate.generate_statistics">true</prop>
				<!-- 一次读的数据库记录数 -->
				<prop key="hibernate.jdbc.fetch_size">50</prop>
				<!-- 释放jdbc连接 -->
				<prop key="hibernate.connection.release_mode">auto</prop>
				<!-- 数据库超时自动连接 -->
				<prop key="hibernate.autoReconnect">true</prop>
				<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
				<!-- 开启二级缓存 -->
				<!-- <prop key="hibernate.cache.use_query_cache">true</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
				<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop> -->
			</props>
		</property>
	</bean>
	<!-- 事务管理器配置 -->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	
	
	<!-- aop事务处理 ********************* start *************************-->
	<tx:annotation-driven/>  
	<!-- 启动@AspectJ支持 -->
	<bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"/> 		 
    <!-- 启动@AspectJ支持 -->
	<!-- <aop:aspectj-autoproxy/> -->
	<!-- 自动搜索切面类 -->
    <context:component-scan base-package="test.testAction"><!--  annotation-config="true" -->
    	<!-- <context:exclude-filter type="annotation" expression="org.aspectj.lang.annotation.Aspect"/> -->
    </context:component-scan>

	<!-- 定义切点和织入 --> 
	<aop:config proxy-target-class="true">
		<aop:advisor pointcut="execution(* test.testDao..*DaoImpl.*(..))" advice-ref="txAdvice"/>
		<aop:advisor pointcut="execution(* test..*ServiceImpl.*(..))" advice-ref="txAdvice"/>
	</aop:config>
	<!-- 定义切面 -->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="get*" read-only="true" />
			<tx:method name="find*" read-only="true" />
			<tx:method name="query*" read-only="true" />
			<tx:method name="update*" read-only="false"/>
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>
	<!-- aop事务处理 ********************* end *************************-->	
	
	<!-- bean注入 ********************** start ****************************-->
	<bean id="AdviceTest" class="test.testAction.AdviceTest"></bean>	
	<bean id="ftd" class="test.testDao.impl.FirstTestDaoImpl"></bean>
	<bean id="fts" class="test.testServices.impl.FirstTestServiceImpl">
		<property name="firstTestDao" ref="ftd"></property>
	</bean>
	<bean id="firstTestAction" class="test.testAction.FirstTestAction">
		<property name="firstTestService" ref="fts">
		</property>
	</bean>	
	<!-- bean注入 *********************** end ***************************-->

</beans>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值