Execution failed for task ':findMainClass'.

直接上错误信息

D:\devops\learn\SpringBootDemo>gradle build -x test
> Task :findMainClass FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':findMainClass'.
> org.gradle.api.tasks.SourceSetOutput.getCla

* Try:
Run with --stacktrace option to get the stack
option to get more log output. Run with --sca

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
4 actionable tasks: 1 executed, 3 up-to-date

解决办法:
在build.gradle中添加如下代码:

apply plugin: 'application'


mainClassName = 'com.xxx.xxx.xxx.xxxApplication'

重新编译即可
下面给出完成的build.gradle脚本


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

apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

mainClassName = 'com.xxx.xxx.xxx.SpringBootDemoApplication'

group = 'com.hezs.learn.springboot'
version = '0.0.1-SNAPSHOT'

jar{
   baseName = 'springbootdemo'
   version = '1.0.0'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8


repositories { 
  maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
} 


dependencies {
	compile "org.springframework.boot:spring-boot-starter-amqp:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-data-jpa:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-thymeleaf:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-web:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-data-redis:${sprintBootVersion}"
	compile "mysql:mysql-connector-java:6.0.3"
	compile "org.flywaydb:flyway-core:3.2.1"
	annotationProcessor 'org.projectlombok:lombok:1.16.12'
	testCompile "org.springframework.boot:spring-boot-starter-test:${sprintBootVersion}"
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

banche168

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值