Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring Boot how to replace string in Springboot Application Class

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading