1

I create a mven project and I punt my persistence.xml in /src/main/resources/META-INF/persistence.xml

This is my folder structure: enter image description here

This is my persistence.xml

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">

    <persistence-unit name="esercizioCRUD" transaction-type="RESOURCE_LOCAL">

        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <class>it.model.OggettoDaVendere</class>

        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/postgres"/>
            <property name="javax.persistence.jdbc.user" value="postgres"/>
            <property name="javax.persistence.jdbc.password" value="***"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>        
        </properties>
    </persistence-unit>
</persistence>

In my pom.xml there are all dependencies like hibernamte-entitymangaer, etc

When I call :

public static void main(String[] args) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("esercizioCRUD");
        emf.createEntityManager();
    }

I don't know why. Anyone can help me?

Doflamingo
  • 11
  • 3
  • Where is `esercizioCRUD` this coming from? the Persistence Unit on that file is named: `CRUD` – maress Jul 15 '18 at 20:08
  • @maress sorry I have edited first and I edit esercizioCRUD in CRUD for wrong, In the code I put esercizioCRUD in everywhere but I obtain these exception! – Doflamingo Jul 15 '18 at 20:25
  • Note that that exception will pop up and can possibly be misleading you from the true problem. It might help a lot if you show your pom.xml. Seems there are a lot of issues with pulling in the correct dependencies for other users; you might want to make sure that you have all the correct ones too. Check out the comments in this stackoverflow discussion: https://stackoverflow.com/questions/1158159/no-persistence-provider-for-entitymanager-named – GuitarStrum Jul 16 '18 at 04:14

0 Answers0