'Intellij and jar file: No Persistence provider for EntityManager named xxx

I use intellij to create a jar package, but it does not work correctly.
After it is created and all the external library jar files are created as well, when I start the program I get the following error.

Mai 13, 2022 4:54:38 NACHM. javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log
WARNING: javax.persistence.spi::No valid providers found.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named xxx
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    at utils.EntityManagerUtil.createEntityManagerConnection(EntityManagerUtil.java:35)
    at utils.EntityManagerUtil.getEntityManager(EntityManagerUtil.java:26)
    at sql.SQLSupplier.<init>(xxx.java:11)
    at sql.SQLAlso.<init>(xxx.java:8)
    at module.Also.<init>(xxx.java:24)
    at factory.Factory.getFactory(Factory.java:17)
    at Main.main(Main.java:14)

The persistence.xml file is properly configured and is used directly by the program, when it is started on intellij.
The location of the persistence.xml file is in /scr/java/resources/META-INF.
I do not understand whether the location of the file in this case is wrong or you have to change something else



Solution 1:[1]

Try placing it here: src/main/resources/META-INF/persistence.xml

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon