簡體   English   中英

@Value 在第三方 jar spring boot 中的類文件中

[英]@Value inside class file in third party jar spring boot

我正在將舊的基於 Spring XML 配置的應用程序遷移到 Spring Boot,並且有第三方 jars 具有@Value("$引用的屬性。我嘗試加載放置在新 Spring 中的/resources下的自定義屬性文件啟動工作區並使用@PropertySource("classpath:file")加載它,但在 Spring Boot 運行期間,似乎沒有加載該屬性並出現以下錯誤:

     Could not resolve placeholder 'com.example.propertyName' in value "${com.example.propertyName}"
     at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) 
     ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]

您可以使用注釋 @Value 綁定屬性值,然后在其上提及鍵。

您可以按照以下鏈接查看端到端示例

點擊

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM