[英]How to read application.properties value inside the constructor in spring boot?
[英]Spring Boot passing value / using method inside the application.properties
例如:
我有一個名為Path.java的類
在Path.java中,我有getter方法“getPort()”,返回int 8080
在application.properties中,我想使用server.port =“getPort()”
怎么樣?
我想外化數據源。 我已經有一個類從外部.txt文件中獲取信息。 我需要在application.properties中使用這個類。
比如,spring.datasource.url = ?? getURL()??
Path.java
如何在Path.java
獲取port
。 然后只需重用該信息。 無法在屬性文件中調用方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.