my programm can't find the configuration file (persistence.xml). Can someone help me? I already tried to put the file in the same folder as "PersonDAO.java". Stacktrace: Stacktrace and DAO sourcecode Project structure: Project strucutre
Not sure how you are building, but if you have resource
or resources
folder, put it in:
resources/META-INF/persistence.xml
That is the normal convention to get file bundled in your JAR
. If you go against the convention, you will most likely have to modify your build script to include it.
That is also where JPA
looks for it (jar/META-INF/persistence.xml)
If you put in the same folder as PersonDAO.java
, you will have to instruct your build system to copy it to the conventional location, because even if xml
files from the source directory are included in the jar
, they will still be in the package directory.
As mentioned in the Project Structure snapshot, resources/META-INF/persistence.xml is the correct location.
Please verify the jar, if the file exists in the packaged jar. If not verify your maven configuration.
Please share the error log, if not successful.
The problem was that the META-INF folder was in the wrong directory, the folder was under WebContent and it should be under SRC. DIRECTORY Thank you and I wish you all a good day. Kind regards Nikola
META-INF文件夹必须位于src文件夹中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.