Home > Mobile >  Spring Boot how to replace string in Springboot Application Class
Spring Boot how to replace string in Springboot Application Class

Time:05-04

my main file looks as follows.

@SpringBootApplication
@OpenAPIDefinition(info = @Info(title = "Test", version = "0.1"))
@SecurityScheme(
        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")
                }

        ))
)
@EnableScheduling
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.

CodePudding user response:

The following should do the trick

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

and obviously in your application.propperties

your.custom.path=http://localhost:8080/auth/realms/master/protocol/openid-connect/auth
  • Related