O código estava funcionando direitinho mas simplesmente parou de funcionar. Estava usando o javax e achei que era o problema, depois passei para o jakarta. O erro é `mai. 21, 2023 3:21:23 PM jakarta.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log WARNING: jakarta.persistence.spi::No valid providers found. Exception in thread "main" java.lang.ExceptionInInitializerError at br.com.julia.loja.testes.CadastroDeProduto.main(CadastroDeProduto.java:21) Caused by: jakarta.persistence.PersistenceException: No Persistence provider for EntityManager named lojaAlura at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:86) at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at br.com.julia.loja.util.JPAUtil.(JPAUtil.java:11) ... 1 more
Process finished with exit code 1 ` Meu persistence.xml está assim:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
<persistence-unit name="lojaAlura">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/loja" />
<property name="jakarta.persistence.jdbc.user" value="root" />
<property name="jakarta.persistence.jdbc.password" value="MUNhr34" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="jakarta.persistence.schema-generation.database.schema" value="loja" />
</properties>
</persistence-unit>
</persistence>
Fiz e refiz o projeto do início ao fim, seguindo cada detalhe, mas o erro continua.