Struts2之application.xml文件

<?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-3.0.xsd
		                    http://www.springframework.org/schema/context 
		                    http://www.springframework.org/schema/context/spring-context-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/aop 
		                    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> 

	<!-- 配置数据源 -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="url" value="${jdbc.url}" />
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>
	<!-- 配置外部数据库连接信息-->
	<context:property-placeholder location="classpath:db.properties"/>
	<!-- 创建SessionFactory,这是spring整合hibernate的核心 -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<!-- 1.配置datasource -->
		<property name="dataSource" ref="dataSource"></property>
		<!-- 2.配置Hibernate属性 -->
		<property name="hibernateProperties">
			<value>
				hibernate.hbm2ddl.auto=update
				hibernate.show_sql=true
				hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
			</value>
		</property>
		<!-- 3.配置映射文件 -->
		<property name="mappingLocations">
			<list>
				<value>classpath:cn/ssh/domain/*.hbm.xml</value>
			</list>
		</property>
	</bean>
	
	<!-- 
	配置事务
	 -->
	<!-- 1.配置事务管理器 -->
	<bean id="transManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	
	<!-- 2.配置事务通知 -->
	<tx:advice id="txAdvice" transaction-manager="transManager">
		<tx:attributes>
			<tx:method name="save*" isolation="DEFAULT" propagation="REQUIRED" read-only="false"/>
			<tx:method name="update*" isolation="DEFAULT" propagation="REQUIRED" read-only="false"/>
			<tx:method name="delete*" isolation="DEFAULT" propagation="REQUIRED" read-only="false"/>
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>
	
	<!-- 3.配置切面 -->
	<aop:config>
		<aop:pointcut expression="execution(* cn.ssh.service..*.*(..))" id="aopPointcut"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="aopPointcut" />
	</aop:config>
	
	<!--  配置基础的Dao,在其他的DAO中只需要继承即可 -->
	<bean id="baseDao" abstract="true">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	<!-- 导入相关配置 -->
	<import resource="classpath:applicationContext-dao.xml"/>
	<import resource="classpath:applicationContext-service.xml"/>
	<import resource="classpath:applicationContext-action.xml"/>
	<import resource="classpath:activiti-context.xml"/>
	
	
		
</beans>   

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值