当前位置: 首页 > 知识库问答 >
问题:

Gradle multi project不下载依赖项

逑翰翮
2023-03-14

我有一个MultiProject gradle,但在我的控制器模块中gradle似乎没有下载spring引导依赖项(或任何其他的东西)。根级构建运行顺利,没有任何错误,但我不能导入任何依赖项类到我的源代码。

以下是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)
}

编辑:settings.gradle

rootProject.name = 'MozartWeb'
include 'MozartModel', 'MozartWebSite', 'MozartWebSiteClient'

任何帮助都将不胜感激。

共有1个答案

鲜于海
2023-03-14

好的,好的!所以别管我!考虑到我将项目导入了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.

希望这能帮助那些被这种蠢事困住的人。

C ya

 类似资料:
  • 我正试图使用Gradle从Maven Central下载我最新发布的依赖项: 当尝试构建时,我得到一个错误: 但是io。github。iltotore:core:1.0-fixed不在lib的pom中,我的朋友可以毫无错误地使用它。 为了解决这个问题,我尝试了: > 删除~/. gradle/中的缓存 使用Intellij IDEA使缓存无效 删除我的maven local 但这个问题仍然存在。

  • 我希望有人能帮忙。 在一台全新的windows机器上。在下载和运行最新版本的eclipse(indigo)之前,我已经下载并安装了java jdk。 3: 4:

  • 问题内容: 当我输入command go build时,我有一个项目具有来自bitbucket上私人存储库的多个依赖项。我得到这个错误 无法识别的导入路径“ bitbucket.xxx.xx / xx / x” x509:证书由未知授权机构签名 我已经尝试了几种方法,例如添加令牌 git config –global http.extraheader令牌 配置为ssh git config –gl

  • 我正在学习创建java ee web应用程序。在intellij idea中,我使用项目向导创建了一个项目:Java Enterprise->Web Application。然后,我在项目根中创建了一个构建文件.gradle,并在终端中调用、。这是构建文件。Gradle 当我添加依赖项并进行渐进式构建时,它们不会加载到项目中。例如,Gson库在代码中不可用。如何告诉Gradle下载这些库以便我可以

  • 我正在尝试添加以下依赖项: