Spring bean property file path


















Viewed 5k times. Improve this question. John Doe John Doe 8, 10 10 gold badges 46 46 silver badges 69 69 bronze badges. Add a comment. Active Oldest Votes.

Improve this answer. How to give path for windows? Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. Spring - Bean Definition Advertisements. Previous Page. Next Page. Useful Video Courses.

More Detail. Previous Page Print Page. Save Close. ApplicationContext itself is a type of MessageSource. SO just implement ApplicationContextAware and use the applicationContext object to get required message like: applicationContext. From this object call the getMessage key. Hi apurav, Thanks for the reply. NoSuchMessageException: No message found under code 'resource. ResourceBundle class and completely different from PropertyPlaceholderConfigurer.

So i don't think i will be able to read property configured in PropertyPlaceholderConfigurer using messageSource Please correct me if i am wrong. Sean Clark. Hey, If you are desperate to use java. Properties then why not just read the file in as you would do in any other non Spring application? Why complicate your Spring configuration and maintenance for something so simple? Hey, Well that is fine, but in that case what is wrong with Apurav Chauhan's solution?

What is the reason that you don't want to use the Value annotation? If you can explain why you can't just inject the username and password in this way then perhaps we will be able to give you a more suitable solution Hi Sean, The problem is we are using spring 2.

My requirement is that i have to read some file whose path is specified in. The number of such path can vary from 1 to n number. Hope i am clear with my requirement -Hemant.

Ok, So do you use annotations at all? There are so many ways you could go about doing this



0コメント

  • 1000 / 1000