【发布时间】:2017-09-15 01:20:27
【问题描述】:
我目前正在使用 gradle 作为构建工具构建Kotlin、Spring Boot 服务。我正在尝试使用此处找到的步骤自动扩展在我的application.properties 文件中找到的属性:
我的版本如下:
- kotlin: 1.1.4-3
- spring boot: 1.5.6.RELEASE
- gradle: 3.5.1
当我运行 ./gradlew bootRun 时,我收到以下错误:
java.lang.IllegalArgumentException: Could not resolve placeholder 'myServiceName' in value "${myServiceName}"
接着是:
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@510aeb93: startup date [Fri Sep 15 10:59:51 AEST 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@68edf5bb
build.gradle:
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'org.springframework.boot'
processResources {
filesMatching('application.properties') {
expand(project.properties)
}
}
gradle.properties:
myServiceName=potato-service
application.properties:
info.app.name=${myServiceName}
这些错误在应用程序启动后出现,并且 spring 正在尝试加载属性文件。
有趣的是,如果我将试图在 application.properties 中替换的变量更改为 myServiceName123,例如,gradle 在 processResources 阶段会失败。
【问题讨论】:
标签: spring-boot gradle kotlin