1

I have a endpoint using @RequestMapping(), but currently it just contains a hardcoded String as the path. Is there someway to do that in a configureable way. Currently we use a @Configuration which sources different propertySources.

Example of endpoint(as it is now)

@RestController
@RequestMapping("endpoint-path")
public class Endpoint {....}

Example how Config class is

@Configuration
@PropertySource("....")
@ConfigurationProperties
@Validated
public class EndpointConfiguration {...}

Just mentioning that I dont just want to reference the propertyfile, I want to reference the property class. Not as below

@RestController
@RequestMapping("${endpoint.path}")
public class Endpoint {....}

EDIT: So As the comment mention lets see an example how I could want it "somewhat" like, as I don't suppose it succeed as that.

@RestController
@RequestMapping(EndpointConfiguration.getEndpoint().getPath())
public class Endpoint {....}

any other ways to define the request mapping of a class with a @Configuration, as it was said annotation would have to know at compile time.

Wisienkas
  • 1,602
  • 2
  • 17
  • 22
  • dont understand what you want to do? Can you show it? – Patrick Sep 06 '17 at 11:46
  • @mark-rotteveel How is this the same question. It seems you have not at all read it. I CLEARLY defined that I was not looking for a propertyFile lookup. – Wisienkas Sep 06 '17 at 12:36
  • 1
    Well, you can't. Hardcoded strings or strings with Spring expression language are the only way. That is a limitation of annotations in Java (the value must be known at compilet time). – Mark Rotteveel Sep 06 '17 at 12:37
  • @mark-rotteveel. In that case that is an answer to my question, but redirecting it as a duplication is clearly **incorrect** – Wisienkas Sep 06 '17 at 12:38
  • I disagree, the answer to that question quotes the documentation, which makes clear that what you want is not possible. If you disagree with that assessment, I suggest that you make an edit to your question so it triggers a reopen review and will see what other reviewers think. – Mark Rotteveel Sep 06 '17 at 12:43
  • @markRotteveel you could argue that. but in that case the duplicate part is only the answer rather than the question. quoting above statement of "marked duplicate" is **This question was marked as an exact duplicate of an existing question** – Wisienkas Sep 06 '17 at 12:45

0 Answers0