Spring Boot how to replace string in Springboot Application Class

my main file looks as follows.

@OpenAPIDefinition(info = @Info(title = "Test", version = "0.1"))
        name = "security_auth", type = SecuritySchemeType.OAUTH2, in = SecuritySchemeIn.HEADER,
        flows = @OAuthFlows(implicit = @OAuthFlow(
                authorizationUrl = "http://localhost:8080/auth/realms/master/protocol/openid-connect/auth",
                tokenUrl = "http://localhost:8080/auth/realms/master/protocol/openid-connect/token",
                scopes = {
                        @OAuthScope(name = "read"),
                        @OAuthScope(name = "write")

public class TestApplication {
    public static void main(String[] args) {SpringApplication.run(TestApplication.class, args);}


Is there a way to set the authorizationUrl and tokenUrl by env var ( application.properties)?
The required parameter is String, so I cannot use @Value to inject the value.

>Solution :

The following should do the trick

authorizationUrl = "${your.custom.path}",

and obviously in your application.propperties


Leave a Reply