Gradle Execution failed for task ':xxxx:findMainClass'.

bogon:smart wangxizhong$ gradle build  -x test
Loading.....
:server:compileJava UP-TO-DATE
:server:processResources UP-TO-DATE
:server:classes UP-TO-DATE
:server:jar
:client:compileJava
:client:processResources UP-TO-DATE
:client:classes
:client:findMainClass FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':client:findMainClass'.
> Unable to find a single main class from the following candidates [smart.server.ServerApplication, smart.client.ClientApplication]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED



环境:Boot多项目构建,出现了多个application入口,gradle无法识别主main

解决方案:在gradle.build文件中添加以下代码

 mainClassName = 'smart.client.ClientApplication'
apply plugin: 'application'




修改后的文件:
buildscript {
    ext {
        springBootVersion = '1.5.2.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
ext {
    applicationInfo = [
            'author'   : 'WangXiZhong',
            'language' : 'java',
            'crateDate': '2017/03/22'
    ]
}

allprojects {
    version = '1.0.0-SNAPSHOT'
    apply plugin: 'idea'

}

subprojects {
    group = 'smart'
    apply plugin: 'java'
    apply plugin: 'application'
    apply plugin: 'org.springframework.boot'
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    mainClassName = 'smart.client.ClientApplication'
    buildDir=new File(rootProject.getBuildDir().getAbsolutePath())
    dependencies {
        compile('org.springframework.boot:spring-boot-starter')
        compile('org.springframework.boot:spring-boot-starter-aop')
        compile('org.springframework.boot:spring-boot-starter-data-redis')
        compile('org.springframework.boot:spring-boot-starter-web')
        runtime('mysql:mysql-connector-java')
        testCompile('junit:junit:4.12')
    }
    repositories {
        mavenCentral()
    }
    dependencyManagement {
        imports {
            mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.SR6"
        }
    }
}





  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值