直接上错误信息
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}"
}