[英]Persistence object cannot find persistence unit from persistence.xml
[英]Hibernate cannot find Persistence.xml
我有一個使用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
放在此處,但沒有工作。
我也曾嘗試在文件系統上創建相同的文件夾結構,但它也無法正常工作。
將其放在WEB-INF/classes
。 這是Web應用程序的類路徑的根。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.