gs-accessing-data-jpa
gs-accessing-data-jpa copied to clipboard
Getting error entityManagerFactory not found
APPLICATION FAILED TO START
Description:
Parameter 0 of method demo in hello.Application required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
Try cleaning your ~/.m2 directory and running it again.
@gregturn saved my life!
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.5.RELEASE:run (default-cli) on project gs-accessing-data-jpa: An exception occurred while running. null: Invoca tionTargetException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocatio n of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException: javax.xml.bind.JAXBException
i ran these, but it didn't help: mvn clean install mvn dependency:purge-local-repository clean install
i found out i had to add some dependency tags in pom.xml:
<!-- Java 8 = JAX-B Version 2.2.8 -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
now it works.
the referenced maven pom.xml
needs to be updated:
https://raw.githubusercontent.com/spring-guides/gs-accessing-data-jpa/master/initial/pom.xml
I added the following:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
Fixed in #36