我有一个多项目 gradle,但在我的 Controller 模块中,gradle 似乎没有下载 spring-boot 依赖项(或任何其他的东西)。根 gradle 构建运行平稳,完全没有错误,但我无法将任何依赖项类导入到我的源代码中。
这是gradle文件:
多项目的根 build.gradle
apply plugin: 'idea'
subprojects {
apply plugin: 'idea'
}
// Ensure the IWS Workspace file is also deleted (this is not the default)
task cleanIdea(dependsOn: [cleanIdeaProject, cleanIdeaWorkspace, cleanIdeaModule],
type: Delete,
overwrite: true,
description: 'Cleans IDEA project files (IML, IPR, IWS)',
group: 'IDE')
task clean(description: 'Deletes the build directory produced by Gradle and the out directory produced by IntelliJ IDEA.',
group: 'build') << {
delete "${buildDir}", 'out'
}
内部项目 build.gradle
def version = '0.0.1'
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE')
//classpath 'com.github.ben-manes:gradle-versions-plugin:0.3'
}
}
apply plugin: 'java' // http://www.gradle.org/docs/current/userguide/java_plugin.html
apply plugin: 'application' // http://www.gradle.org/docs/current/userguide/application_plugin.html
apply plugin: 'war' // http://www.gradle.org/docs/current/userguide/war_plugin.html
apply plugin: 'spring-boot'
springBoot {
mainClass = "com.mozart.Mozart"
}
idea.module {
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
configurations {
all {
exclude(group: 'commons-logging') // Never include commons-logging (use SLF4J instead)
exclude(group: 'log4j') // Never include log4j (use SLF4J instead)
}
}
jar.manifest {
attributes("Implementation-Title": "Mozart Web Site", "Implementation-Version": version)
}
processResources << {
// Workaround for Tomcat. Tomcat requires META-INF to be a non-empty subdirectory of
// build/classes/main in order for Servlet 3.0 Application Initializer scanning to work
copy {
// http://gradle.org/docs/current/userguide/working_with_files.html
from "src/main/resources/META-INF/dummy-file-required-by-tomcat.txt"
into "${sourceSets.main.output.classesDir}/META-INF"
}
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
}
task runService(description: 'Starts up the service using Tomcat.',
group: 'application') << {
logging.setLevel(LogLevel.INFO)
ant.java(classname: 'com.thoughtworks.learnangularjs.server.TomcatServer',
classpath: sourceSets.test.runtimeClasspath.asPath,
fork: true,
failonerror: true)
}
编辑:
设置.gradle
rootProject.name = 'MozartWeb'
include 'MozartModel', 'MozartWebSite', 'MozartWebSiteClient'
任何帮助将不胜感激。
最佳答案
好的好的!所以别管我!考虑到我将项目导入 IntelliJ,我认为我不需要显式调用 gradle idea……但就是这样! =/
在检查调试时,我发现依赖关系正在被解决......
14:50:40.050 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration MozartWeb:MozartWebSite:unspecified(classpath).
14:50:40.050 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency MozartWeb:MozartWebSite:unspecified(classpath) -> org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE(classpath)
14:50:40.051 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE
14:50:40.051 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE using repositories [maven, MavenRepo]
14:50:40.051 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache module-metadata.bin (C:\Users\Igor\.gradle\caches\modules-2\metadata-2.16\module-metadata.bin)
14:50:40.052 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.IvyXmlModuleDescriptorParser] post 1.3 ivy file: using exact as default matcher
14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE' in 'maven'
14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Using org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE from Maven repository 'maven'
14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE(default).
14:50:40.053 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE(default) -> org.springframework.boot:spring-boot-loader-tools:1.3.0.RELEASE(compile,runtime)
14:50:40.054 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version org.springframework.boot:spring-boot-loader-tools:1.3.0.RELEASE
但是类路径搞砸了......
14:50:40.066 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in C:\Users\Igor\AppData\Local\Temp\gradle7086690745953254784.bin. Wrote root MozartWeb:MozartWebSite:unspecified:classpath.
希望这可以帮助其他人坚持这种愚蠢的事情。
咿呀
关于Gradle 多项目不下载依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34001258/