我对 kotlin 比较陌生,我无法理解弹簧自动装配
kotlin.UninitializedPropertyAccessException: lateinit property applicationContext has not been initialized
运行此程序时出现上述错误:
@SpringBootTest
internal class MeterResourceAdapterTest () {
@Autowired
private lateinit var applicationContext: ApplicationContext
@Test
fun toMeterReadingResourceList() {
print(applicationContext.applicationName)
.....//I hope my implementation can be ignored
}
这里发生了什么?顺便说一句,为什么需要lateinit,以及“它”何时被初始化?