我的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'}
但是添加后:
实现(“ 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”:“未设置有效的配置文件,回退到默认配置文件:default”,“ context”:“默认”}
我尝试添加特定版本的依赖项,例如:
实现组:“ org.springframework.boot”,名称:“ spring-boot-starter-data-jpa”,版本:“ 2.0.7.RELEASE”
它没有用。
我还试图删除整个.gradle文件夹,然后重新下载。
应用程序从nexus获取依赖项。
我该如何解决?
答案 0 :(得分:0)
您只能具有一个悬挂。我注意到您已经添加了依赖项。
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
那么您就不应再次添加它。