我目前正在構建一個使用gradle作爲構建工具的Kotlin
,Spring Boot
服務。我試圖自動展開在我application.properties
文件中找到的屬性,使用這裏找到步驟:在kotlin/spring引導中使用Gradle屬性擴展
我的版本如下:
- 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[email protected]510aeb93: startup date [Fri Sep 15 10:59:51 AEST 2017]; parent: org.spring[email protected]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階段失敗。