Problem
Ich versuche, die neueste Version Kotlin (1.2.10) mit auch zu laufen, die neueste Federverschluß (2.0.0.M7). In der lokalen Umgebung alles ist in Ordnung, aber -boottime intellij schreit: Frühlings-Boot 2 & Kotlin 1.2.1: veraltete wersion der Laufzeit
ich Outdated Kotlin Runtime gesehen haben, aber meiner Meinung nach ist es nicht verbunden, so ... Das ist verdächtig wegen meiner folgenden build.gradle, wo es ist nur eine Version von Kotlin (nur rechts) [Frontend ist auch gradle Build aber node.js ein - eckig, nicht Kotlin deps]:
buildscript {
ext {
kotlinVersion = '1.2.10'
springBootVersion = '2.0.0.M7'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/libs-milestone-local" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
classpath 'org.springframework:springloaded:1.2.6.RELEASE'
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
group = 'com.witkups'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/libs-milestone-local" }
}
dependencies {
compile project(":frontend")
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-webflux')
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.microsoft.sqlserver:mssql-jdbc')
compile('com.fasterxml.jackson.datatype:jackson-datatype-jsr310')
compile('com.fasterxml.jackson.module:jackson-module-kotlin:2.9.2')
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
compile("io.jsonwebtoken:jjwt:0.7.0")
testCompile('com.h2database:h2')
testCompile('org.springframework.security:spring-security-test')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('io.projectreactor:reactor-test')
}
und das beunruhigt mich in Build wegen warnen (und nicht in Tests wie ich denke):
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/home/travis/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.2.10/19bc012f8c4cd6b705bd6512263777cc19bcf259/kotlin-reflect-1.2.10.jar (version 1.2)
/home/travis/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre8/1.2.10/71c98c16b4bed3f754c6c398f9da8300ecb0a669/kotlin-stdlib-jre8-1.2.10.jar (version 1.2)
/home/travis/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.1.61/59dfce93b1995717338435dd974884007d8e8474/kotlin-stdlib-jre7-1.1.61.jar (version 1.1)
/home/travis/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.1.61/fa7813a26c548c9c412dd2d42fb466cfcd8dcf3c/kotlin-stdlib-1.1.61.jar (version 1.1)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath or use '-Xskip-runtime-version-check' to suppress this warning
:spring-boot-server:compileTestJava NO-SOURCE
:spring-boot-server:processTestResources
:spring-boot-server:testClasses
:spring-boot-server:testPicked up _JAVA_OPTIONS: -Xmx2048m -Xms512m
com.witkups.carsharing.CarSharingApplicationTests > contextLoads FAILED
java.lang.IllegalStateException
Caused by: java.lang.IllegalStateException
Caused by: java.lang.NoClassDefFoundError
Caused by: java.lang.ClassNotFoundException
1 test completed, 1 failed
:spring-boot-server:test FAILED
Test:
package com.witkups.carsharing
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@SpringBootTest
class CarSharingApplicationTests {
@Test
fun contextLoads() {
}
}
Jede mögliche Hilfe geschätzt :) PS: JDK 8
Lösung
Ich habe folgende Zeilen in build.gradle
Skript hinzugefügt:
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-stdlib-jre7:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
und funktioniert wie ein Zauber. Tests gestoppt versagt, wenn ich
ersetzt@RunWith(SpringRunner::class)
mit
@ExtendWith(SpringExtension::class)
Wie wurde Ihr IntelliJ-Projekt erstellt? Hast du wie vorgeschlagen getan und Abhängigkeit für Kotlin gesehen? Haben Sie sich Modul- und Bibliotheksdefinitionen angesehen? Ich nehme an, es liegt daran, dass Sie das Idea-Plugin für Gradle verwendet haben, um das Projekt zu generieren, und es wurde eine ältere Version von Kotlin zum Bibliothekspfad hinzugefügt. Ich würde empfehlen, Gradle-Projekte direkt in IntelliJ zu importieren und das Ideen-Plugin für Gradle nicht mehr zu verwenden. – Mikezx6r