Получение ошибки после установки sourceCompatility на 1.6 - Неподдерживаемая версия major.minor 52.0 - PullRequest
0 голосов
/ 17 апреля 2020

Мне нужно запустить флягу приложения весенней загрузки. Моя машина установлена ​​на java 1.8, но конечный сервер включен java 1.7. Пробовал несколько вещей, чтобы создать банку, которая будет работать на java 1.7. Но пока ничего не получалось. Я пробовал 1,7, 1,6, а также 1,5. Но ни одна из них не сработала.

build.gradle выглядит следующим образом:

buildscript {
    ext {
        springBootVersion = '2.2.6.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath(
                "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

plugins {
    id 'org.springframework.boot' version '2.2.6.RELEASE'
    id 'java'
}
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'

/// ------------


compileJava {
    options.incremental = true
    options.fork = true
    options.failOnError = false
}

assert hasProperty('javaHome'): "Set the property 'javaHome' in your your gradle.properties pointing to a Java 6 or 7 installation"
assert hasProperty('targetJavaVersion'): "Set the property 'targetJavaVersion' in your your gradle.properties to '1.6' or '1.7'"

java {
    sourceCompatibility = JavaVersion.toVersion(targetJavaVersion)
}

def javaExecutablesPath = new File(javaHome, 'bin')
def javaExecutables = [:].withDefault { execName ->
    def executable = new File(javaExecutablesPath, execName)
    assert executable.exists(): "There is no ${execName} executable in ${javaExecutablesPath}"
    executable
}

tasks.withType(AbstractCompile) {
    options.with {
        fork = true
        forkOptions.javaHome = file(javaHome)
    }
}
tasks.withType(JavaExec) {
    executable = javaExecutables.java
}

tasks.withType(Javadoc) {
    executable = javaExecutables.javadoc
}
tasks.withType(Test) {
    executable = javaExecutables.java
}


///--------
group = 'com.abc.grt'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.6'
targetCompatibility = '1.6'

jar {
    baseName = "someApp"
    version = '0.0.1-SNAPSHOT'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    compile "org.springframework.integration:spring-integration-sftp:4.3.7.RELEASE"
    // https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-context
    compile group: 'org.springframework.cloud', name: 'spring-cloud-context', version: '2.2.2.RELEASE'

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}


bootJar {
    baseName = "someApp"
    version = '0.0.1-SNAPSHOT'
    mainClassName = 'com.abc.grt.someApp.SomeApplication'
}

test {
    useJUnitPlatform()
}

Машина назначения выдает исключение:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/JarLauncher : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
...
...