title: Running spring boot build: Error creating bean with name 'entityManagerFactory' defined in class path
body: <p>I have built a Spring Boot app and I am now ready to deploy it.
  However, I try to build a "fat jar" which will contain everything but it seems that I have done something wrong but it is unclear what.</p>
  
  <p><strong>application.properties (true credentials removed)</strong></p>
  
  <pre><code>#Template engine conf
  spring.thymeleaf.check-template-location=true
  
  #Database stuff
  spring.jpa.hibernate.ddl-auto=update
  spring.datasource.url= jdbc:mysql://localhost:3306/db
  spring.datasource.username=username
  spring.datasource.password=pw
  </code></pre>
  
  <p><strong>Gradle build script (some names changed):</strong></p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '2.0.2.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  
  group = 'se.myapp'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = 1.8
  
  repositories {
      mavenCentral()
  }
  
  bootJar {
      classifier = 'boot'
      mainClassName = 'se.myapp.myapp.SnartledigApplication'
      launchScript()
      baseName = 'myapp'
      version =  '0.1.0'
  }
  
  dependencies {
      compile('org.springframework.boot:spring-boot-starter-actuator')
      compile('org.springframework.boot:spring-boot-starter-data-jpa')
      compile('org.springframework.boot:spring-boot-starter-thymeleaf')
      compile('org.springframework.boot:spring-boot-starter-web')
      compile('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect')
      runtime('mysql:mysql-connector-java')
      testCompile('org.springframework.boot:spring-boot-starter-test')
  }
  </code></pre>
  
  <p>Then I am running <code>gradle clean build</code> and try to execute the jar <code>java -jar build/libs/my-jar-yada-yada.jar</code> only to get the following exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
          at se.snartledig.snartledig.SnartledigApplication.main(SnartledigApplication.java:13) [classes!/:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
          at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
          at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [snartledig-0.1.0-boot.jar:na]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [snartledig-0.1.0-boot.jar:na]
          at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [snartledig-0.1.0-boot.jar:na]
          at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [snartledig-0.1.0-boot.jar:na]
  Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
          at org.hibernate.boot.spi.XmlMappingBinderAccess.&lt;init&gt;(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
          at org.hibernate.boot.MetadataSources.&lt;init&gt;(MetadataSources.java:87) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.&lt;init&gt;(EntityManagerFactoryBuilderImpl.java:209) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.&lt;init&gt;(EntityManagerFactoryBuilderImpl.java:164) ~[hibernate-core-5.2.17.Final.jar!/:5.2.17.Final]
          at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:51) ~[spring-orm-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE]
          ... 24 common frames omitted
  Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
          at java.base/java.net.URLClassLoader.findClass(Unknown Source) ~[na:na]
          at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ~[na:na]
          at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[snartledig-0.1.0-boot.jar:na]
          at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ~[na:na]
          ... 35 common frames omitted
  </code></pre>
  
  <p>What am I doing wrong? I am using windows.</p>
  
  <p><strong>EDIT, java version</strong></p>
  
  <pre><code>java 10.0.1 2018-04-17
  Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
  Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
  </code></pre>