One of our teams implemented the loading properties this way (see the pseudo-code below) and recommends this approach correctly, since the client application using this freely saves the properties in any file. Unlike the widely used property propertyholderfigurer.
context.xml applications
<bean class="com.mypackage.Myclass"> <property name="xml" value="classpath:"{com.myapp.myproperty1}"> </property> </bean>
config.properties
com.myapp.myproperty1=data.xml
edit: I would add that it is data.properties, not data.xml. We want to load the properties file (this properties file is specified in config.properties as "property". Com.myapp.myproperty1 = data.properties
java class
import org.springframework.core.io.Resource; public class Myclass { private Resource xmlField;
Is it correct to use spring core.io.Resource?
Another reason is that the client application wants to load an environment-specific configuration. I suggested using theconfigurer property and using maven profiles to generate an environment-specific build
Could you advise which one is suitable? and if it differs in different scenarios, please help me point them out?
thanks
source share