代码之家  ›  专栏  ›  技术社区  ›  João Menighin

Gradle-带java7的SpringBoot

  •  1
  • João Menighin  · 技术社区  · 6 年前

    我有一个SpringBoot应用程序在java8上运行得很好。我刚刚被告知,我们将部署的服务器应用程序只能运行Java7或更低版本。这仍然是一个小的应用程序,但我只是想改变 build.gradle 让它工作。我被错误缠住了:

    Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/SpringApplication : Unsupported major.minor version 52.0
    

    这是我的 :

    buildscript {
        ext {
            springBootVersion = '1.5.16.RELEASE'
        }
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }
    
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    
    group = 'com.menighin'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
    
    repositories {
        mavenCentral()
    }
    
    
    dependencies {
        compile("org.springframework.boot:spring-boot-starter-web")
        compile('org.springframework.boot:spring-boot-starter-data-rest')
    //  compile('org.springframework.boot:spring-boot-starter-security')
        compile('org.springframework.session:spring-session-core')
        runtime('org.springframework.boot:spring-boot-devtools')
        compileOnly('org.projectlombok:lombok')
        testCompile('org.springframework.boot:spring-boot-starter-test')
    //  testCompile('org.springframework.security:spring-security-test')
    }
    

    我刚把枪放下 springBootVersion sourceCompatibility targetCompatibility 1.7 . 你知道我还需要改什么版本吗? SpringBoot documentation on 1.5.16

    1 回复  |  直到 6 年前
        1
  •  0
  •   x80486    6 年前

    我不认为那会飞。这个类/JAR是为JDK编译的 1.8 . 因此 UnsupportedClassVersionError .

    在任何情况下,这个版本都是 SNAPSHOT . 我建议使用 1.5.15 GA 1.7 除非写文档的人做错了什么。参考 System Requirements .