2017-09-25 670 views
1

我正在使用Intellij IDEA 2017.2.4Gradle 4.0.1 我有幾個Spring Boot服務。而且我面臨運行它們的問題,由於缺少依賴關係,它們可能會以隨機方式啓動而失敗。Intellij IDEA不解決Gradle依賴關係

我有build.gradle父項目:

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url "https://repo.spring.io/snapshot" } 
     maven { url "https://repo.spring.io/milestone" } 
     maven { url "https://plugins.gradle.org/m2/" } 
     mavenLocal() 
    } 

    dependencies { 
     classpath("io.spring.gradle:dependency-management-plugin:$dependencyManagementPluginVersion") 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion") 
    } 
} 

allprojects { 
    apply plugin: 'java' 
    apply plugin: 'idea' 

    group = '***' 
    version = '***' 
} 

subprojects { 
    sourceCompatibility = 1.8 
    targetCompatibility = 1.8 

    processResources { 
     filesMatching('**/*.yml') { 
      expand(project.properties) 
     } 
    } 

    apply plugin: 'io.spring.dependency-management' 

    dependencyManagement { 

     imports { 
      mavenBom("org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion") 
      mavenBom("org.springframework.boot:spring-boot-dependencies:$springBootVersion") 
     } 

     dependencies { 
      dependency "com.google.cloud:google-cloud-storage:$googleCloudStorageVersion" 
      ... 
      dependency "org.junit.jupiter:junit-jupiter-api:$junitVersion" 
     } 
    } 
} 

和一個小孩項目build.gradle

apply plugin: 'org.springframework.boot' 

repositories { 
    mavenCentral() 
    maven { url "https://repo.spring.io/snapshot" } 
    maven { url "https://repo.spring.io/milestone" } 
    mavenLocal() 
} 

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

在某些情況下lombok依賴遺漏,在其他javax依賴。它表明依賴不存在。

enter image description here

但之後我按01​​並再次它的工作原理建立。

enter image description here

也許有人遇到同樣的問題,有它的一些解決方案?

+0

你能在這裏發表您'build.gradle'文件,好嗎? –

+0

@AndriiAbramov有一些基本的東西,沒有什麼特別的 –

回答

0

看來你有問題,lombok依賴。第一步是確保龍目島添加爲您編譯時的依賴,例如:

repositories { 
    mavenCentral() 
} 

dependencies { 
    compileOnly 'org.projectlombok:lombok:1.16.18' 
} 

第二步是確保您有最新的安裝在您的IntelliJ lombok插件。當您嘗試在IDE內編譯您的項目時,這一點非常重要。另一件可能有用的事情是在Intellij配置中設置自動更新依賴項。

+0

一切都是最新的,並且我也有相同的版本龍目島的依賴性。 –