1

I want to define RequestMapping using the value inside a properties file (file inside resource folder).

@RequestMapping(value = "X", produces = "application/json") public String hello() { } 

How can I read "X" from a properties file?

EDIT: I try with @PropertySource annotation, but it doesn't work in "X"

EDIT 2: I also try this, and it works but not in @RequestMapping(value = "X")

@Bean public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() { PropertySourcesPlaceholderConfigurer propertyConfigurer = new PropertySourcesPlaceholderConfigurer(); propertyConfigurer.setLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/**/abc.properties")); return propertyConfigurer; } 

Thanks

1
  • I asked nearly the same. My problem is solved, see this answer Commented Feb 6, 2017 at 8:20

1 Answer 1

2

It should be possible to use placeholders in @RequestMapping. Read the documentation for more details

@RequestMapping("${foo.bar}", produces = "application/json") public String hello() { .... } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.