简体   繁体   中英

Spring Boot passing value / using method inside the application.properties

For example:

I have a class called Path.java

In Path.java, I have getter method "getPort()" that returns int 8080

In application.properties, I want to use server.port = "getPort()"

How?

I want to externalize the datasource. I already have a class that grabs the information from the external .txt file. I need to use this class inside the application.properties.

Like, spring.datasource.url = ??getURL()??

Thinking how you get the port in your Path.java . Then just reuse that information. There is no way to call a method in a properties file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM