spring配置@Transactional到方法上的异常怎么解决,在线求救啊
在inte易做图ce里的方法上添加@Transactional是可以正常工作的,现在需要加到class的方法上就出了下面的错误
Error creating bean with name 'testController': Injection of autowired dependencies failed
XML是这样的
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
abstract="false" lazy-init="default" autowire="default">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
--------------------编程问答-------------------- @Controller 这个加上了/? --------------------编程问答--------------------
@Controller是有的,去掉@Transactional是能正常工作的,inte易做图ce里面也有@Transactional,也是正常的,加到class里就这样了 --------------------编程问答-------------------- @Resource --------------------编程问答-------------------- 你是注入testController失败吧 --------------------编程问答--------------------
testController:
@Autowired
TestService testService;
testService:
--------------------编程问答--------------------
public class TestService{
@Transactional
public int insert(){
``````
}
}
加上@Transactional后就注入失败,好像是testController中的
@Autowired
TestService testService;
这出的问题 --------------------编程问答--------------------
--------------------编程问答--------------------
@Autowired
@Qualifier("testController")
TestService testService;
--------------------编程问答-------------------- 虽然不知道楼主在说什么。但是感觉好像很厉害的样子 --------------------编程问答-------------------- 不知道你怎么搞的,你检查一下的配置,你哪里应该注入什么应该自己清楚吧,注解不清楚去查文档。。spring好久没用了我。。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: cn.test.TestService TestController.testService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.test.TestService ] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=AccountController)}
补充:Java , Java EE