在使用springMVC时,[email protected],[email protected]编程语言

问题出现的场景:

在使用spring mvc时,[email protected], [email protected]

我的配置如下:

<mvc:annotation-driven />

<context:component-scan base-package=”org.test”/ >

<bean id=”txManager”  class=”org.springframework.jdbc.datasource.DataSourceTransactionManager”> 
  <property name=”dataSource” ref=”dataSource” /> 
</bean> 

<tx:annotation-driven transaction-manager=”txManager” /> 

原因是

component-scan和事务所在的上下文不一样,component-scan所在的配置是由servlet加载的,事务所在的配置文件是由Listener加载的。 

我的解决方法

安装下面的配置,在应用启动时,[email protected]

<context:component-scan base-package=”org.test” > 
  <context:exclude-filter type=”annotation”  expression=”org.springframework.stereotype.Service” /> 
</context:component-scan> 

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/16083.html

(0)
上一篇 2021年7月19日 18:59
下一篇 2021年7月19日 18:59

相关推荐

发表回复

登录后才能评论