Search code examples
javaspring-bootapplication.properties

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()??


Solution

  • 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.