Tag: 春季

Spring不能处理返回通用内部Kotlin类的方法

我是Kotlin新手,所以也许我误解了一些东西,但这个班级: @Component open class SimpleStoreBuilder { open fun <T : Entity> build(tableName: String): Store<T>? { return Store() } inner class Store<T:Entity> } 引发此运行时异常 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storeBuilder' defined in file [xxx\StoreBuilder.class]: Initialization of bean failed; nested exception is java.lang.reflect.GenericSignatureFormatError: Signature Parse error: expected '<' or ';' but got . Remaining input: .Store<TT;>; […]

Kotlin – lateinit TestRestTemplate不能初始化集成测试

我使用kotlin开发了一个spring-boot应用程序 – 总体情况进展顺利。 (spring 1.5.6.RELEASE,kotlin 1.1.4-3) 无论如何,我在回顾一些示例代码之后添加了我的第一个控制器测试,并且遇到了这个恼人的错误: kotlin.UninitializedPropertyAccessException:lateinit属性restTemplate尚未初始化 kotlin.UninitializedPropertyAccessException:lateinit属性testRestTemplate尚未初始化 at com.thingy.controllers.ProductSetControllerTest.getTestRestTemplate(ProductSetControllerTest.kt:16) at com.thingy.controllers.ProductSetControllerTest.testGet(ProductSetControllerTest.kt:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at […]

Kotlin测试失败从命令行与ClassNotFoundException但从IntelliJ工作

我在这里有一个Kotlin Spring Boot项目。 它有一些测试,从IntelliJ运行得很好,但是当我从命令行运行,失败,出现以下错误。 BUILD FAILED in 1m 12s 7 actionable tasks: 7 executed asarkar:license-report-kotlin$ ./gradlew clean test > Task :compileKotlin Using kotlin incremental compilation > Task :compileTestKotlin Using kotlin incremental compilation > Task :test 2017-07-16 21:43:06.345 INFO 2956 — [ Thread-13] scaAnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@54fa5525: startup date [Sun Jul 16 21:42:04 PDT 2017]; root […]

Kotlin&Spring Boot @ConfigurationProperties

如何使用Kotlin正确初始化Spring Boot中的 ConfigurationProperties? 目前我喜欢在下面的例子中: @ConfigurationProperties("app") class Config { var foo: String? = null } 但它看起来相当丑陋,实际上foo是不可变的,foo是不变的 , 应该在启动过程中初始化,将来不会改变 。