How to register properties loaded with Spring?

Is it possible to simply write the entire contents of a property file loaded by spring with <context:property-placeholder /> ?

thanks

+7
source share
2 answers

You can set the log level org.springframework.core.env.PropertySourcesPropertyResolver to "debug". Then you can see the value of the properties at resolution.

+10
source

You can do it as follows:

 <context:property-placeholder properties-ref="myProperties"/> <bean id="myProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> .. locations </list> </property> </bean> 

and add a bean log similar to the one below (annotations based on slf4j api are based here):

 @Component public class PropertiesLogger { private static Logger logger = LoggerFactory.getLogger(PropertiesLogger.class); @Resource("myProperties") private Properties props; @PostConstruct public void init() { for (Map.Entry<Object, Object> prop : props.entrySet()) { logger.debug("{}={}", prop.getKey(), prop.getValue()); } } } 
+2
source

All Articles