[英]Intellij IDEA doesn't resolve Gradle dependencies
我正在使用Intellij IDEA 2017.2.4
和Gradle 4.0.1
我只有几个Spring Boot服务。 而且我在运行它们时遇到问题,由于缺少依赖关系,它们在以随机方式启动时可能会失败。
我有一个与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
依赖关系中。 它表明依赖项不存在。
但是,当我按下Refresh All Gradle Projects
并再次构建它时,它就可以工作了。
也许有人遇到了同样的问题,并有解决方案?
看来您对lombok
依赖性有问题。 第一步是确保将lombok添加为您的编译时依赖项,例如:
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.18'
}
第二步是确保您有最新的lombok
对你的IntelliJ安装的插件。 当您尝试在IDE中编译项目时,这一点非常重要。 可能有所帮助的另一件事是设置为在Intellij配置中自动更新依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.