为了让spring使用注释进行自动扭曲,您必须告诉spring。在您的xml配置中(假设您还没有
context:component-scanelement)添加一个
context:annotation-config。这将指示Spring应用程序上下文来扫描注解(如
@Autowired,
@Inject,
@Resource等)做自动装配。
还要确保要
EntityManagerFactory注入的
Engine类(该类)是spring托管的bean。Spring只会将引用注入到Spring托管的bean中。



