Reputation: 807
When I am running my unit test I these two errors
org.hibernate.jpa.boot.internal.PersistenceXmlParser doResolve INFO: HHH000318: Could not find any META-INF/persistence.xml file in the classpath
and
javax.persistence.PersistenceException: No Persistence provider for EntityManager named dbContext
I don't get them both because as you can see in the image en persistence.xml file below this text everything is there that he is complaining about.
and here you have my persistance.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="dbContext">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="{urltodb}"/>
<property name="hibernate.connection.autocommit" value="false"/>
<property name="hibernate.connection.username" value="{myusername}"/>
<property name="hibernate.connection.password" value="{mypassword}"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.connection.CharSet" value="utf8"/>
<property name="hibernate.connection.characterEncoding" value="utf8"/>
<property name="hibernate.connection.useUnicode" value="true"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
Upvotes: 0
Views: 1391
Reputation: 24444
Your folder structure is completely mixed up:
src
-Folder is marked as source-folder (blue), so the subfolder main is interpreted as Java-Packagesources/main
-folder That's why Intellij interprets it as package main.resources.META-INF
.How your folder structure should look like:
See also: How to create a test directory in Intellij 13?
Upvotes: 1