我想通过JPA @Entity
注释一个类,所以我添加了Spring的@Component/@Resource/@Configurable
注解,但它不允许我自动装入那个类。JPA @Entity和Spring之间的冲突@ Component/@ Resource/@ Configurable
是否需要其他注释?
样品是:
@Component
@Entity
@Table
public class Employee{
@Autowired
TestService testService;
...
}
凡类TestService
标注有@Service
。
请向downvoted的人请求理由。 –
我不是downvoter,但你为什么要这么做? Hibernate应该管理'@ Entity'对象的生命周期,而不是Spring,这是'@ Autowired'(和其他bean注释一起)的用处。 –
我了解Predrag,但我有一个要求。 –