properties - Look up a dynamic property at run-time in Spring from PropertySourcesPlaceholderConfigurer? -


The best way to do this is not fixed. We have created a jar which can be used by various projects. Other projects depending on this jar are required to provide specific properties defined in one of their spring properties. (Our jar should not be taken into consideration as to what those property files are called.)

Using @Value ("$ {some.prop}") works great for most properties , Although now we need to see that the name of the property is dynamic for example:

  int val = getSomeVal (); String propNeeded = foo.getProperty ("foo." + Val + ".dynamic.prop"); To get my access, what should be "foo"? I saw the environment injecting the environment, however, with all my Goggles it seems that it does not load from an XML property-placeholder definition. (Even if the property is set as Bean Def for the site placeholder configuration.) You have to use @propertysource, however my main config is an XML file, so listen Not sure how the environment works (I can not really go to 'Old School' and can view the asset file as a square path because since then I do not know the name of user defined file.)  

This is not particularly the case for creating service class ApplicationContextAware, but if I have done so, how can I access the built-in PropertySourcesPlaceholderConfigurer? what I feel? Need to get a property dynamically?

The second option is that I force the users of jar to declare a bean by the name which I can see

     

And then I look at the appProps injection as properties and from there I do not like this approach because it forces the users of the library to give a filename by normal ID. I think the best solution is to get a handle to the underlying property source placeholder configuration in my service class ... I'm not sure how to do this now?

Just why not do PropertySource can be defined through its XML configuration and then I can only inject the environment?

Thanks for any suggestions that I have to make.

You can declare to read from the same source as that PropertySourcesPlaceholderConfigurer just like this you just @Autowire MessageSource (or implement MessageSourceAware to your Been) and can use it to retrieve your properties.

The main reason for using ReloadableResourceBundleMessageSource is to recover the I18N messages.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -