在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/云計算  Java  Scala/ Gradle build命令構(gòu)建基于SpringCloud項目,執(zhí)行到某一個子項

Gradle build命令構(gòu)建基于SpringCloud項目,執(zhí)行到某一個子項目時,提示程序包不存在

整個項目是基于 spring cloud

父項目的 build.gradle 配置:

group 'com.xxx.yyy'
version '0.1.0'

buildscript {
    ext {
        springBootVersion = '1.5.10.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath('se.transmode.gradle:gradle-docker:1.2')
    }
}

subprojects {
    apply plugin: 'idea'
    apply plugin: 'java'
    apply plugin: 'docker'
    apply plugin: 'org.springframework.boot'
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    
    sourceSets {
        main {
            java.srcDir "src"
        }
    }
    repositories {
        mavenCentral()
    }
    configurations {
        all*.exclude module: 'spring-boot-starter-logging'
        all*.exclude module: 'logback-classic'
    }
    dependencyManagement {
        imports {
            mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.SR3'
        }
    }
    dependencies {
        compile('org.springframework.boot:spring-boot-starter')
        compile('org.springframework.boot:spring-boot-starter-log4j2')
        compile('org.springframework.boot:spring-boot-starter-test')
        compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml')
    }
}

子項目的配置就比較簡單了
子項目1:

group 'com.xxx.yyy'
version '0.1.0'
archivesBaseName = 'prj1'

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    // ...
}

子項目2:

group 'com.xxx.yyy'
version '0.1.0'
archivesBaseName = 'prj2'

dependencies {
    compile project(":prj1")
}

在父項目目錄下,執(zhí)行 gradle build -x test 命令時

> Task :prj2:compileJava
ConsumerHelper.java:5: 錯誤: 程序包com.xxx.yyy.zzz不存在

請問這個是什么原因?qū)е?。?!?/p>

回答
編輯回答
悶油瓶

把主項目中的 build.gradle 內(nèi)容一行一行條這個位置做測試,改了下倉庫,最后終于可以了。。。

group 'com.xxx.yyy'
version '0.1.0'

buildscript {
    ext {
        springBootVersion = '1.5.10.RELEASE'
    }
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath('se.transmode.gradle:gradle-docker:1.2')
    }
}

subprojects {
    apply plugin: 'idea'
    apply plugin: 'java'
    apply plugin: 'docker'
    apply plugin: 'org.springframework.boot'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    }
    configurations {
        all*.exclude module: 'spring-boot-starter-logging'
        all*.exclude module: 'logback-classic'
    }
    dependencyManagement {
        imports {
            mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Edgware.SR3'
        }
    }
    dependencies {
        compile('org.springframework.boot:spring-boot-starter')
        compile('org.springframework.boot:spring-boot-starter-log4j2')
        compile('org.springframework.boot:spring-boot-starter-test')
        compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml')
    }
}

順便在某些 module 下加上了

bootRepackage {
    enabled = false
}
2017年6月20日 06:24
編輯回答
兔囡囡

父項目需要新建一個 setting.gradle ,具體配置如下:

include 'sub_1', 'sub_2'

rootProject.name = "root_project"
2017年7月4日 00:25