【发布时间】:2016-09-14 05:29:16
【问题描述】:
当我在我的服务类中添加“@Transactional(readOnly=false)”注释时,我收到以下错误
说明:
无法将 bean 'studentService' 作为 '
com.student.service.StudentServiceImpl' 因为它是 JDK 动态的 实现的代理:com.student.service.StudentService
示例代码:
@Service("studentService")
@Transactional(readOnly=false)
public class StudentServiceImpl implements StudentService {
}
public interface StudentService {
}
行动:
考虑将 bean 作为其接口之一注入,或通过在
@EnableAsync和/或@EnableCaching上设置proxyTargetClass=true来强制使用基于 CGLib 的代理。进程以退出代码 1 结束
是什么原因造成的?
【问题讨论】:
-
如果您尝试使用 JRE 构建项目,那么您可以将其更改为 JDK 吗?您的类路径中是否有所有方面相关的 jar?
-
我错了,我已经自动装配了Interface的实现类。
-
你可以用那个答案回答你自己的问题,因为我遇到了同样的事情,这帮助我解决了它。谢谢!
标签: java spring-boot dependency-injection