【问题标题】:java.lang.UnsupportedClassVersionError: org/springframework/boot/gradle/plugin/SpringBootPlugin : Unsupported major.minor version 52.0java.lang.UnsupportedClassVersionError:org/springframework/boot/gradle/plugin/SpringBootPlugin:不支持的major.minor版本52.0
【发布时间】:2017-08-14 17:27:44
【问题描述】:

我的单曲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

【问题讨论】:

    标签: java spring gradle spring-boot


    【解决方案1】:

    我在使用 maven 构建时遇到了类似的问题。就我而言,该项目似乎是使用 jdk 1.8 构建的,但在 jdk 1.7 上运行。

    这个话题帮助我进入了这个问题:Unsupported major.minor version 52.0

    【讨论】:

      【解决方案2】:

      问题是我改变了JAVA_HOME 想法开始之后,我从想法运行gradle build。因此在idea重启后问题就解决了

      【讨论】:

      • 是的,我将 JAVA_HOME 更改为更正 jdk 版本,然后它对我有用。
      【解决方案3】:

      对我来说,我正在使用 Gradle。这是因为我之前配置USER_HOME/.gradle/gradle.properties文件使用jdk版本7。所以,它不会使用JAVA_HOME。

      解决方法是删除 gradle.properties 文件。

      【讨论】:

        猜你喜欢
        • 2017-09-11
        • 2018-08-06
        • 1970-01-01
        • 2017-04-17
        • 2018-08-24
        • 1970-01-01
        • 2017-01-23
        • 2017-06-13
        • 1970-01-01
        相关资源
        最近更新 更多