2017-09-25 282 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

一切都是最新的,并且我也有相同的版本龙目岛的依赖性。 –