我想通過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,但我有一個要求。 –