[存个档]SSH spring配置文件(XML)

本文来自:fair-jm.iteye.com 转截请注明出处

 

hibernate用的是4.2.6 spring是4.0.2

 

这回是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:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
	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:component-scan base-package="com.cc.crm" />

	<context:annotation-config />

	<!--映入src下的jdbc.porpertise 文件 -->
	<context:property-placeholder location="classpath:jdbc.properties" />
	
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="myDataSource" />
		<!-- 映入映射文件 -->
		<!-- <property name="mappingLocations"> <list> <value>classpath:com/products/*.hbm.xml</value> 
			</list> </property> -->
		<property name="packagesToScan">
			<list>
				<value>com.cc.crm.vo</value>
			</list>
		</property>

		<!-- 加入在外面写好的数据库中的注解 -->
		<property name="hibernateProperties" ref="hibernateProperties" />
	</bean>

	<!-- 配置数据源 -->
	<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>

	<!-- 数据库中的相关属性 -->
	<bean id="hibernateProperties"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="properties">
			<props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
			</props>
		</property>
	</bean>
	<!-- 事务配置 -->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<!-- 配置事务的传播特性 -->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="load*" propagation="REQUIRED" />
			<tx:method name="get*" propagation="REQUIRED" read-only="true"/>
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="delete*" propagation="REQUIRED" />
			<tx:method name="add" propagation="REQUIRED" />
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>
	<!-- 那些类的哪些方法参与事务 -->
	<aop:config>
		<aop:pointcut id="allServiceMethod"
			expression="execution(* com.cc.crm.service.impl.*.*(..))" />
		<aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" />
	</aop:config>

</beans>

 还有一个配置文件:

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/crm
jdbc.username=root
jdbc.password=
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.hbm2ddl.auto=update
hibernate.current_session_context_class=thread
hibernate.show_sql=true
hibernate.format_sql=true

 

 

JDK8用spring3.2.X会爆错 ClassReader的错 是ASM 要么hijack一下进行本地编译 要么换用spring 4.X 后者我试了下直接替换没什么大问题.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值