交易注释错误 [英] Transactional annotation error
问题描述
当我在我的服务类中添加 @Transactional(readOnly = false)
注释时,我收到以下错误
When I put "@Transactional(readOnly=false)
" annotation in my Service class I get the following error
描述:
bean'studentService'无法注入
'com .student.service.StudentServiceImpl
'因为它是一个实现的JDK动态
代理:com.student.service.StudentService
The bean 'studentService' could not be injected as a '
com.student.service.StudentServiceImpl
' because it is a JDK dynamic proxy that implements: com.student.service.StudentService
示例代码:
@Service("studentService")
@Transactional(readOnly=false)
public class StudentServiceImpl implements StudentService {
}
public interface StudentService {
}
行动:
考虑注入豆子作为其接口之一或通过在
@EnableAsync
上设置proxyTargetClass = true
来强制使用基于CGLib的代理或@EnableCaching
。
Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting
proxyTargetClass=true
on@EnableAsync
and/or@EnableCaching
.
流程完成d,退出代码1
Process finished with exit code 1
造成这种情况的原因是什么?
推荐答案
在spring boot项目中,尝试添加:
in spring boot projects, try to add :
spring.aop.proxy-target-class=true
到你的application.properties
to your application.properties
OR
@EnableAspectJAutoProxy(proxyTargetClass = true)
到春季启动入口点。
这篇关于交易注释错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!