我使用Play Framework2.2,Hibernate作为JPA提供者(4.2.8.Final)、Spring (4.0.1.RELEASE)和Spring数据JPA (1.4.3.RELEASE)。
我使用spring来实例化控制器,并使用上下文:在应用程序加载时进行组件扫描,以收集和配置所有所需的依赖项(存储库等)。
我用play框架配置spring的方式是
public class Global extends GlobalSettings {
private ApplicationContext applicationContext;
@Override
public void onStart(Application arg0) {
String configLocation = Play.application().configuration().getString("spring.context.location");
applicationContext = new ClassPathXmlApplicationContext(configLocation);
}
@Override
public <A> A getControllerInstance(Class<A> type) throws Exception {
return applicationContext.getBean(type);
}
}
以及应用程序-context.xml中的相关部分是
当第一次加载应用程序时,一切都非常好。然而,一旦我在视图或控制器和应用程序重新加载中做了任何更改,Spring数据Jpa就会中断,并抱怨我的模型不是托管类型的。
Caused by: java.lang.IllegalArgumentException: Not an managed type: class models.User
虽然这不是一个一般的问题,重新启动工作很好,如果有人能提供任何输入来重新加载applicationContext完全在播放重新加载。
发布于 2014-02-22 02:27:03
我也遇到过同样的问题。将Spring数据JPA1.4.3改为1.4.2。Changing解决了这个问题。我没有时间进一步研究这个问题,所以我不知道原因是什么。
这个项目是一个很好的起点:https://github.com/typesafehub/play-spring-data-jpa,但是它使用1.3个版本的Spring。
https://stackoverflow.com/questions/21821725
复制相似问题