I\'m developing application using spring data jpa,hibernate,mysql,tomcat7,maven and it\'s create error.I\'m trying to figure it out but i failed.
error are Cannot
Spring Data JPA by default looks for an EntityManagerFactory named entityManagerFactory
. Check out this part of the Javadoc of EnableJpaRepositories
or Table 2.1
of the Spring Data JPA documentation.
That means that you either have to rename your emf
bean to entityManagerFactory
or change your Spring configuration to:
<jpa:repositories base-package="your.package" entity-manager-factory-ref="emf" />
(if you are using XML)
or
@EnableJpaRepositories(basePackages="your.package", entityManagerFactoryRef="emf")
(if you are using Java Config)
just updated the springboot version to 2.1.3 and it worked of me
In my specific case I seemed to have been missing the dependency
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
Had this issue when migrated spring boot 1.5.2 to 2.0.4.
Instead of creating bean I've used @EnableAutoConfiguration
in the main class and it solved my problem.
I had the same problem and got it resolved by deleting .m2 maven repo (C:\Users\user\ .m2)
In your application context, change the bean with id from emf
to entityManagerFactory
:
<bean id="emf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="org.wahid.cse.entity" />
<property name="dataSource" ref="dataSource" />
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider"></bean>
</property>
</bean>
To
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="org.wahid.cse.entity" />
<property name="dataSource" ref="dataSource" />
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider"></bean>
</property>
</bean>