gpt4 book ai didi

spring-boot - 将spring-data-jpa添加到gradle文件后出错?

转载 作者:行者123 更新时间:2023-12-03 05:39:37 26 4
gpt4 key购买 nike

我的gradle文件中有这个依赖项。

dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.cloud:spring-cloud-starter-sleuth')
implementation('org.springframework.cloud:spring-cloud-starter-zipkin')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
implementation group: 'ch.qos.logback.contrib', name: 'logback-json-classic', version: '0.1.5'
implementation group: 'ch.qos.logback.contrib', name: 'logback-jackson', version: '0.1.5'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.24'
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.oracle', name: 'ojdbc', version: '6.0'
compileOnly('org.projectlombok:lombok')
testImplementation('org.springframework.boot:spring-boot-starter-test')
integrationTestCompile('org.springframework.boot:spring-boot-starter-test')
integrationTestCompile group: 'com.github.tomakehurst', name: 'wiremock', version: '2.1.6'
integrationTestCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
integrationTestCompile group: 'ch.qos.logback.contrib', name: 'logback-json-classic', version: '0.1.5'
integrationTestCompile group: 'ch.qos.logback.contrib', name: 'logback-jackson', version: '0.1.5'
integrationTestCompile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'}

但是添加后:

implementation("org.springframework.boot:spring-boot-starter-data-jpa")



应用程序无法启动。

我的整个gradle文件是:

buildscript {
ext {
springBootVersion = '2.0.7.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

plugins {
id "org.sonarqube" version "2.5"
id "io.franzbecker.gradle-lombok" version "1.14"
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'

group = 'com.doruk'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {

maven {
url "http://nexus.internal/repository/maven-public/"
}

maven {
url "http://nexus.internal/repository/maven-snapshots/"
}

maven {
url "http://nexus.internal/repository/maven-releases/"
}
mavenCentral()
jcenter()
}

ext {
springCloudVersion = 'Finchley.SR2'
}

configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}

dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation('org.springframework.cloud:spring-cloud-starter-sleuth')
implementation('org.springframework.cloud:spring-cloud-starter-zipkin')
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
implementation group: 'ch.qos.logback.contrib', name: 'logback-json-classic', version: '0.1.5'
implementation group: 'ch.qos.logback.contrib', name: 'logback-jackson', version: '0.1.5'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.24'
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.oracle', name: 'ojdbc', version: '6.0'
compileOnly('org.projectlombok:lombok')
testImplementation('org.springframework.boot:spring-boot-starter-test')
integrationTestCompile('org.springframework.boot:spring-boot-starter-test')
integrationTestCompile group: 'com.github.tomakehurst', name: 'wiremock', version: '2.1.6'
integrationTestCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
integrationTestCompile group: 'ch.qos.logback.contrib', name: 'logback-json-classic', version: '0.1.5'
integrationTestCompile group: 'ch.qos.logback.contrib', name: 'logback-jackson', version: '0.1.5'
integrationTestCompile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

sonarqube {
properties {
property "sonar.jacoco.itReportPath", "$buildDir/jacoco/integrationTest.exec"
}
}

sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir
sourceSets.integrationTest.output.resourcesDir = sourceSets.integrationTest.output.classesDir

task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
}


check.dependsOn integrationTest
integrationTest.mustRunAfter test

bootJar {
mainClassName = "com.doruk.customer.Main"
}


它在没有spring-boot-starter-jpa的情况下完美运行,但是如果添加它,当我运行它时卡在

{"timestamp":"2018-12-24 03:00:31.400","level":"INFO","thread":"main","logger":"com.doruk.customer.Main","message":"No active profile set, falling back to default profiles: default","context":"default"}



我尝试添加特定版本的依赖项,例如:

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.7.RELEASE'



它没有工作。

我还尝试删除整个.gradle文件夹,然后重新下载。

应用程序从nexus获取依赖项。

我该如何解决?

最佳答案

您必须仅具有一个依赖项。我注意到您已经添加了该依赖性。

dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation("org.springframework.boot:spring-boot-starter-data-jpa") //here
然后,您不应该再次添加它。

关于spring-boot - 将spring-data-jpa添加到gradle文件后出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53908112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com