`
jun_fx
  • 浏览: 5279 次
  • 来自: ...
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

spring2 +hibernate3 怎么样配置事务

阅读更多
<?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" 

    xsi:schemaLocation=" 

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd 

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 


	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>jdbc:mysql://localhost:3306/wap</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value>1234</value>
		</property>
	</bean>
	
	<bean id="mySessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>com/model/User.hbm.xml</value>
				<value>com/model/Userinfo.hbm.xml</value>
				<value>com/model/Shangping.hbm.xml</value>
				<value>com/model/Gouwuche.hbm.xml</value>
				</list>
		</property></bean>
	
	<bean id="dao"  abstract="true" >
	<property name="sessionFactory"><ref local="mySessionFactory"/></property>
	</bean>
	
	<tx:advice id="txAdvice" transaction-manager="transactionManager" > 
		<tx:attributes>
		    <tx:method name="add*"/>
			<tx:method name="get*" read-only="true"/>
		</tx:attributes>
	</tx:advice>
	
	 <aop:config>
    	<aop:pointcut id="txAdvicePointcut" expression="execution(public com.services.impl.*(..) )"/>
    	<aop:advisor  pointcut-ref="txAdvice" advice-ref="txAdvicePointcut" />
    </aop:config>
    
     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="mySessionFactory"/>
    </bean>

 

  	<bean id="userDao" class="com.dao.impl.UserDaoImpl" parent="dao" />	
	<bean id="userService" class="com.services.impl.UserServiceImpl" >
	 	<property name="userDao" ><ref local="userDao"/> </property>	 </bean>
	
	<bean id="shangpingDao" class="com.dao.impl.ShangpingDaoImpl" parent="dao" />
	<bean id="gouwucheDao" class="com.dao.impl.GouwucheDaoImpl" parent="dao"></bean>	
	<bean id="shoppingService" class="com.services.impl.ShoppingServiceImpl">
		<property name="shangpingDao"><ref local="shangpingDao"/> </property>
		<property name="gouwucheDao"><ref local="gouwucheDao"/></property>
	</bean>	
 </beans>
	




[org.hibernate.impl.SessionFactoryObjectFactory] - <Not binding factory to JNDI, no JNDI name configured>
2008-04-23 16:12:13,593 DEBUG [org.hibernate.impl.SessionFactoryImpl] - <instantiated session factory>
2008-04-23 16:12:13,593 DEBUG [org.hibernate.impl.SessionFactoryImpl] - <Checking 0 named HQL queries>
2008-04-23 16:12:13,593 DEBUG [org.hibernate.impl.SessionFactoryImpl] - <Checking 0 named SQL queries>
2008-04-23 16:12:13,640 DEBUG [org.springframework.core.CollectionFactory] - <Creating [java.util.LinkedHashSet]>
2008-04-23 16:12:13,656 INFO [org.springframework.orm.hibernate3.HibernateTransactionManager] - <Using DataSource [org.apache.commons.dbcp.BasicDataSource@1a4ded3] of Hibernate SessionFactory for HibernateTransactionManager>
2008-04-23 16:12:13,656 DEBUG [org.springframework.core.CollectionFactory] - <Creating [java.util.LinkedHashSet]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Creating instance of bean '(inner bean)' with merged definition [Root bean: class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Getting BeanInfo for class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found bean property 'class' of type [java.lang.Class]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found bean property 'nameMap' of type [java.util.Map]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found bean property 'properties' of type [java.util.Properties]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.core.CollectionFactory] - <Creating [java.util.LinkedHashMap]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.core.CollectionFactory] - <Creating [java.util.LinkedHashMap]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] - <Adding transactional method [add*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] - <Adding transactional method [get*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.core.CollectionFactory] - <Creating [java.util.LinkedHashSet]>
2008-04-23 16:12:13,656 DEBUG [org.springframework.core.CollectionFactory] - <Creating [java.util.LinkedHashSet]>
2008-04-23 16:12:13,671 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Retrieved dependent beans for bean 'dataSource': [mySessionFactory]>
2008-04-23 16:12:13,671 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Retrieved dependent beans for bean 'mySessionFactory': [transactionManager]>
2008-04-23 16:12:13,671 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Retrieved dependent beans for bean 'transactionManager': [txAdvice]>
2008-04-23 16:12:13,671 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Retrieved dependent beans for bean 'txAdvice': [org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor]>
2008-04-23 16:12:13,671 DEBUG [org.springframework.beans.factory.support.DisposableBeanAdapter] - <Invoking destroy() on bean with name 'mySessionFactory'>
2008-04-23 16:12:13,671 INFO [org.springframework.orm.hibernate3.LocalSessionFactoryBean] - <Closing Hibernate SessionFactory>
2008-04-23 16:12:13,671 INFO [org.hibernate.impl.SessionFactoryImpl] - <closing>
2008-04-23 16:12:13,671 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@544ec1: defining beans [dataSource,mySessionFactory,dao,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,txAdvicePointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor,transactionManager,userDao,userService,shangpingDao,gouwucheDao,shoppingService]; root of factory hierarchy>

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.transaction.interceptor.TransactionInterceptor] to required type [org.springframework.aop.Pointcut] for property 'pointcut'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.transaction.interceptor.TransactionInterceptor] to required type [org.springframework.aop.Pointcut] for property 'pointcut': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.transaction.interceptor.TransactionInterceptor] to required type [org.springframework.aop.Pointcut] for property 'pointcut'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.transaction.interceptor.TransactionInterceptor] to required type [org.springframework.aop.Pointcut] for property 'pointcut': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.transaction.interceptor.TransactionInterceptor] to required type [org.springframework.aop.Pointcut] for property 'pointcut': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:87)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:96)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:83)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:296)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:313)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1176)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:124)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:68)
at com.Test.main(Test.java:28)


应该有很多人会吧,我笨,请指点下。这里谢谢各位了
分享到:
评论
2 楼 juiccee 2008-09-21  
<aop:advisor  pointcut-ref="txAdvice" advice-ref="txAdvicePointcut" />   

这里配反了,应该是
:<aop:advisor  pointcut-ref="txAdvicePointcut" advice-ref="txAdvice" />
1 楼 冷静的偏激 2008-09-19  
我也遇到错误了。Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor'

相关推荐

    Struts2+Spring3+Hibernate4零配置所需全部jar包

    在这个“Struts2+Spring3+Hibernate4零配置所需全部jar包”中,包含了这三个框架运行所必需的库文件,使得开发者无需逐一配置,可以直接在项目中引用这些jar包进行开发。 首先,让我们详细了解一下Struts2框架。...

    struts1.2 + spring2.5 + hibernate3.2框架demo

    2. **配置文件**:struts-config.xml定义Struts的配置,spring-beans.xml管理Spring的bean,hibernate.cfg.xml配置Hibernate的数据库连接,可能还有实体类的映射文件(hbm.xml或使用注解)。 3. **JSP页面**:展示...

    Spring4.0+Hibernate4.0+Struts2.3整合案例

    1、Spring 3.x 对 Hibernate 4.x 不提供 HibernateDaoSupport,所以在dao的实现层注入SessionFactory 2、报错:org.hibernate.HibernateException: No Session found for current thread 意思是必须在...

    struts2.1+spring2.5+hibernate3.3整合之第一步(spring2.5+hibernate3.3)

    3. 配置Hibernate:在Spring配置文件中,配置Hibernate的SessionFactory,并设置数据库连接信息。同时,需要编写实体类和对应的映射文件(`.hbm.xml`),以便Hibernate能够自动管理数据库表。 4. 配置Struts2:创建...

    spring mvc + spring + hibernate 全注解整合开发视频教程 11

    此外,教程可能还会涵盖事务管理的配置,以及如何使用Spring Data JPA进一步简化数据访问层的代码。 整合这三大框架,可以实现高效、灵活且易于维护的Java Web应用。通过注解,开发者可以减少XML配置,提高代码的...

    最新项目系统:Struts2+Spring4+Hibernate4三大框架整合

    开发人员可以通过分析这些文件,了解如何配置Struts2、Spring4和Hibernate4的整合,学习如何在实际项目中应用这三大框架。此外,还可以通过阅读源码,理解它们之间的交互机制,加深对MVC模式和Java Web开发的理解。 ...

    基于struts2+spring2+hibernate3的注册登陆

    6. **文件结构**:尽管没有提供具体的文件列表,但一个标准的Struts2+Spring2+Hibernate3项目通常包含以下部分:源代码(src目录),配置文件(如struts.xml、spring配置文件、hibernate配置文件),Web资源(Web-...

    springmvc+spring+hibernate

    3. **配置Spring**:在src/main/resources下创建applicationContext.xml文件,配置Spring的核心容器,包括Bean定义、数据源、事务管理器等。例如,使用DataSource来连接Oracle数据库,使用...

    SSH - SpringMVC4 + Spring4 + Hibernate4 + c3p0 + Mysql.zip

    Spring的配置文件则会定义数据源、事务管理器、Bean的依赖注入等。Hibernate的配置文件会设置数据库连接参数,实体类的映射等。c3p0的配置则涉及连接池的大小、超时设置等。 总的来说,这个项目展示了如何将这些...

    Spring2.5+hibernate搞定分布式事务

    Spring2.5+hibernate搞定分布式事务Spring2.5+hibernate搞定分Spring2.5+hibernate搞定分布式事务布式事务 第三部分

    Struts2+Spring3+Hibernate4示例

    Struts2、Spring3和Hibernate4是Java Web开发中的三个核心框架,它们分别负责MVC(Model-View-Controller)架构中的控制层、业务层和服务层。本示例结合这三个框架,提供了一种完整的三层架构实现,以提高开发效率和...

    图书管理系统spring+struts+hibernate

    library_ssh2可能是一个包含系统源代码的压缩文件,"ssh2"可能表示系统使用了Struts2、Spring2和Hibernate2这三个框架的早期版本。这个文件中应包含所有必要的Java源代码、配置文件、Web应用相关的资源(如JSP页面、...

    spring mvc + spring + hibernate 全注解整合开发视频教程 04

    Spring还提供了数据源配置、事务配置以及对Hibernate SessionFactory的管理,通过`@EnableTransactionManagement`开启事务管理。 在实际开发中,我们还会用到Spring的其他功能,比如Spring MVC的拦截器...

    spring4+springmvc4+hibernate4 整合

    Spring、SpringMVC和Hibernate是Java开发中三大核心框架,它们的整合是企业级应用开发的常见模式,常被简称为SSH(Spring、SpringMVC、Hibernate)。在本项目"spring4+springmvc4+hibernate4 整合"中,我们将探讨这...

    Struts2+Spring4+Hibernate5整合

    这种整合方式的优势在于,Struts2处理用户交互,Spring提供整体的依赖管理和事务控制,Hibernate则简化了数据库操作。通过它们的协作,可以构建出松散耦合、可测试性高且具有良好架构的Java Web应用。然而,随着...

    struts2+spring4+hibernate

    Struts2、Spring4和Hibernate是Java开发中的三大框架,它们在构建企业级Web应用程序时起着核心作用。本教程将深入探讨这三个框架如何协同工作,以实现高效、灵活和可扩展的电子商务平台。 首先,Struts2是一个基于...

    jsp+Spring+hibernate 博客系统

    在本文中,我们将深入探讨一个采用JSP、Spring和Hibernate技术构建的博客系统。这种组合提供了强大的功能,包括后端业务逻辑管理、持久层支持以及用户友好的前端界面。 **JSP (JavaServer Pages)** JSP是Java的一...

    spring mvc+hibernate实现事务管理(配置文件版)

    本项目是关于如何使用Spring MVC与Hibernate结合来实现事务管理的实践教程,通过MyEclipse自动生成所需的包和配置文件。这里将详细讲解这一过程,以及涉及到的关键知识点。 首先,Spring MVC作为Spring框架的一部分...

    jbpm4整合struts2+spring2.5+hibernate3.3

    在这个整合中,jbpm4需要与Struts2、Spring2.5和Hibernate3.3协同工作,实现流程定义、流程实例管理、事务控制和数据持久化。首先,jbpm4本身拥有一个IOC容器,但为了更好地整合其他框架,通常会选择Spring作为统一...

    整合struts2+spring3+hibernate3所需的jar包

    Struts2、Spring3和Hibernate3是Java Web开发中的三个重要框架,它们分别负责MVC模式中的Action层、业务逻辑层和服务容器层。这三大框架的整合能够提供一个高效、可扩展的后端架构,方便开发者进行复杂的企业级应用...

Global site tag (gtag.js) - Google Analytics