我在Netbeans中使用Hibernate创建了一个web应用程序。由于类路径问题,我无法运行我的应用程序。它找不到我的persistence.xml文件。这是Netbeans中项目的文件夹结构:
Web pages
- META-INF
- persistence.xml
- Web-INF
Source packages
- <default package>
- persistence.xml
com.company.me
- java source files
= (One of the files contains the main() method that i am using to run
the app. I am not running the project as web app but rather as normal app using the main() method as entry point)您可以看到persistence.xml位于两个位置。我只是把它们放在那里测试它是否能找到它们。我从其他一些帖子中读到,persistence.xml一定在src/main/resources中,我试图创建那个文件夹结构,但它不起作用,并将META-INF/persistence.xml放在那里,但它不起作用。
我也曾尝试在文件系统上创建相同的文件夹结构,但效果不佳。
发布于 2016-01-25 22:22:20
将其放入WEB-INF/classes。这是web应用程序类路径的根。
https://stackoverflow.com/questions/34993740
复制相似问题