Spring Boot | parsing Url with query params in properties file with URIComponentBuilder

Viewed 184

I have a URL in my application-local.properties file which looks like

basePath: http://host.com/
endpoint: /endpoint?q={value1}

I am mapping it to variables in a class annotated with @ConfigurationProperties. I am using URLComponentBuilder to build the full URL like this:

 UriComponentsBuilder.fromUriString(basePath).path(properties.endpoint).build(123)

The URL I am getting is this: http://host.com/endpoint%3Fq=123 i.e. the ? gets encoded.

The question is that I don't want to remove query params from the properties file and add them only in the code where I am building the URL. I want to keep the full URI endpoint in the properties file and still be able to generate the correct (without ? being encoded) full URL through URIComponentBuilder

0 Answers
Related