Spring:创建名为'entityManagerFactory'的bean时出错

时间:2018-03-16 10:36:29

标签: java spring jpa spring-boot h2

我在https://spring.io/guides/tutorials/bookmarks/关注教程。我使用了初始化程序并决定使用gradle。在准备构建应用程序或直接运行它时,我收到错误:

  

引起:org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / orm / jpa / HibernateJpaConfiguration.class]中定义名称为'entityManagerFactory'的bean创建错误:init的调用方法失败;嵌套异常是java.lang.NoClassDefFoundError:javax / xml / bind / JAXBException

我猜这是由spring-boot-starter-data-jpacom.h2database:h2引起的,可能与某些版本不匹配有关。但是,我不知道该怎么办。

我的gradle.build:

buildscript {
ext {
    springBootVersion = '2.0.0.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 = 'sfs.examples'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 9.0

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('com.h2database:h2')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

0 个答案:

没有答案
相关问题