我的单个build.gradle看起来如下:
buildscript {
ext {
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileOptions {
sourceCompatibility sourceCompatibility
targetCompatibility targetCompatibility
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-validation')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('com.microsoft.sqlserver:mssql-jdbc')
testCompile('org.springframework.boot:spring-boot-starter-test')
}但是gradle clean build生产:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\objectsharingsystem\build.gradle' line: 16
* What went wrong:
A problem occurred evaluating root project 'object-sharing-system'.
> java.lang.UnsupportedClassVersionError: org/springframework/boot/gradle/plugin/SpringBootPlugin : Unsupported major.minor version 52.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.看来我到处都在使用java 8。
java_home设置为java 8
发布于 2017-03-22 15:23:17
问题是,在JAVA_HOME idea启动之后,我更改了,并从idea运行了gradle build。这样,在idea重新启动之后,问题就得到了解决。
发布于 2017-03-22 14:41:08
在使用maven构建时,我也遇到了类似的问题。在我的例子中,项目似乎是用JDK1.8构建的,但运行在JDK1.7上。
这个话题帮助我进入了这个问题:Unsupported major.minor version 52.0
发布于 2018-08-09 03:33:41
对我来说,我用的是格拉德尔。这是因为我以前将USER_HOME/.gradle/gradle.properties文件配置为使用jdk 7,所以它不会使用JAVA_HOME。
解决方案是删除gradle.properties文件。
https://stackoverflow.com/questions/42954364
复制相似问题