我有以下 Maven 项目结构:
Example
-Persistence
-GWTApp
持久性在
src/main/resources/META-INF
中有persistence.xml ,并且在单一测试中运行良好。我需要在 GWTApp 项目中使用它。因此,我将其添加为依赖项。像这样:
<dependency>
<groupId>com.example</groupId>
<artifactId>Persistence</artifactId>
<version>0.0.1</version>
</dependency>
有了这个,我可以在我的 webapp 中查看和使用持久性类,但是,当我在 eclipse 中运行 webproject 时,我得到了这个错误:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named exemplo
我认为这是因为eclipse在引用webapp项目中的持久性项目的项目之间完成了这个“链接”,而不是使用jar文件。也许我错了,这只是一个猜测。
有人知道我该如何解决这个问题?
提前致谢。
编辑
我做了更多的测试,现在我认为问题出在 GWT 开发模式和 JPA 或其他问题上。
我试图手动将 persistence.xml 复制到
weapp/META-INF
和 target/project-webapp-0.0.1-SNAPSHOT/META-INF
并且错误仍然存在。任何的想法?
最佳答案
您是否正确启动了应用程序? https://developers.google.com/eclipse/docs/faq#gwt_with_maven
特别要注意,您必须“mvn war:exploded”复制您的依赖项 target/myapp-0.0.1-SNAPSHOT/WEB-INF/lib
关于gwt - Eclipse 中的 Maven 子模块 : Resources from one module not found in another,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10252845/