当前位置: 代码迷 >> Java Web开发 >> 求教SSH整合时,spring事务的一个异常 百思不得其解
  详细解决方案

求教SSH整合时,spring事务的一个异常 百思不得其解

热度:6336   发布时间:2016-04-10 22:56:06.0
求教SSH整合时,spring事务的一个错误 百思不得其解


我在整合SSH框架时候,SSH三个框架的正常功能我都测试通过了,就最后一个
spring事务老是报错。百思不得其解,不知道错误从何找起,jar包也加了,xml配置
代码按照教程弄的,应该也没错。我是在spring的配置文件中,采用xml方式
配置事务的,如下:

    <!--第一段: 配置事务管理器  -->
    <bean id="txManager" 
class="org.springframework.orm.hibernate4.HibernateTransactionMana
ger"> 
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    <!--第二段: 配置事务管通知 -->
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="save" propagation="REQUIRED"/>
        </tx:attributes>
    </tx:advice>
    

    <!--第三段: 以xml的方式配置事务-->
    <aop:config>
        <aop:pointcut expression="execution(* com.itcast..*.*
(..))" id="businessService"/>
        <aop:advisor advice-ref="txAdvice" 
pointcut="businessService"/>
    </aop:config>



刚开始我把最后面的   <!--第三段: 以xml的方式配置事务-->    这一段注释掉
,只保留前面两段,测试SSH其他功能,完全正常。后来要测试事务,就把最后的第三
段 <!--第三段: 以xml的方式配置事务--> 的注释打开,前面两段的代码没动,保
持原样,结果测试时候就报错了,报错信息如下:



(PS:相关的sessionFactory dataSource等等的,我都在前面配好了.spring-
tx.jar包也加了)





SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'provinceDAOImpl': Injection of resource 
dependencies failed; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'sessionFactory' defined in class path 
resource [applicationContext.xml]: Cannot resolve reference to 
bean 'myDataSource' while setting bean property 'dataSource'; 
nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'myDataSource' defined in class path 
resource [applicationContext.xml]: Initialization of bean failed; 
nested exception is java.lang.IllegalArgumentException: Pointcut 
is not well-formed: expecting '(' at character position 0
businessService
^

    at 
........................................
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'sessionFactory' defined in class path 
resource [applicationContext.xml]: Cannot resolve reference to 
bean 'myDataSource' while setting bean property 'dataSource'; 
nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'myDataSource' defined in class path 
resource [applicationContext.xml]: Initialization of bean failed; 
nested exception is java.lang.IllegalArgumentException: Pointcut 
is not well-formed: expecting '(' at character position 0
businessService
^

    at 
org.springframework.beans.factory.support.BeanDefinitionValueResol
ver.resolveReference(BeanDefinitionValueResolver.java:329)
    at 
...................................................
    ... 27 more
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'myDataSource' defined in class path 
resource [applicationContext.xml]: Initialization of bean failed; 
nested exception is java.lang.IllegalArgumentException: Pointcut 
is not well-formed: expecting '(' at character position 0
businessService
^

    at 
org.springframework.beans.factory.support.AbstractAutowireCapableB
eanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:52
9)
    at 
............................................
    ... 42 more
Caused by: java.lang.IllegalArgumentException: Pointcut is not 
well-formed: expecting '(' at character position 0
businessService
^


    ... 48 more
------解决方案--------------------
 pointcut="businessService"/>

你不换成 

 pointcut-ref="businessService"/>

试试
  相关解决方案