[英]Spring @Controller and Transactionmanager
I'm having a basic Spring Controller 我有一个基本的Spring控制器
package org.foo;
@Controller
public class HelloWorldController implements IHelloWorldController
{
@RequestMapping(value = "/b/c/", method = RequestMethod.GET)
public void doCriticalStuff(HttpServletRequest request, HttpServletResponse response){
//...
}
}
Tested via curl -X GET http://myIP:myPort/b/c/
Which works fine. 通过
curl -X GET http://myIP:myPort/b/c/
测试curl -X GET http://myIP:myPort/b/c/
哪个工作正常。
If I'm configuring transaction Management via 如果我正在通过配置事务管理
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="helloWorldPC"
expression="execution(* org.foo.IHelloWorldController.*(..)) && !execution(* java.lang.Object.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="helloWorldPC" />
</aop:config>
The mapping is not working any longer. 映射不再起作用。 I get a 404 Error on client side an on Server the Method is not entered.
我在客户端获得404错误,在服务器上没有输入方法。 Doing a JUnit test with a breakpoint in
doCriticalStuff
I can see AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: ...
so the transaction config is used. 在
doCriticalStuff
使用断点执行JUnit测试我可以看到AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: ...
因此使用了事务配置。
But the mapping is not working any longer. 但是映射不再起作用了。 Any ideas?
有任何想法吗?
I'm using Spring 3.0.2.RELEASE 我正在使用Spring 3.0.2.RELEASE
Transactional aspect is applied using dynamic proxy , and it prevents Spring MVC from accessing the @RequestMapping
annotations on the target class. 使用动态代理应用事务方面,它阻止Spring MVC访问目标类上的
@RequestMapping
注释。 You may use <aop:config proxy-target-class="true">
as a workaround. 您可以使用
<aop:config proxy-target-class="true">
作为解决方法。
Spring team says that they wouldn't fix this behaviour for efficiency reasons (see comment on SPR-5084 ) Spring团队表示他们不会出于效率原因修复此行为(请参阅有关SPR-5084的评论 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.