2019-08-28

Caused by: java.lang.IllegalStateException: No persistence units parsed from {classpath*:META-INF/persistence.xml}






Reference URL: https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa


5. Going Full XML-less

Usually, JPA defines a persistence unit through the META-INF/persistence.xml file. Starting with Spring 3.1, the persistence.xml is no longer necessary. The LocalContainerEntityManagerFactoryBean now supports a packagesToScan' property where the packages to scan for @Entity classes can be specified.
This file was the last piece of XML we need to remove. We can now set up JPA fully with no XML.
We would usually specify JPA properties in the persistence.xml file. Alternatively, we can add the properties directly to the entity manager factory bean:
factoryBean.setJpaProperties(this.additionalProperties());
As a side-note, if Hibernate would be the persistence provider, then this would be the way to specify Hibernate specific properties.







add this into your servlet context.xml

<property name="packagesToScan" value="com.howtodoinjava.entity" />








No comments:

Google Referrals