com.github.antelopeframework.spring.config.PropertiesPrinter Maven / Gradle / Ivy
The newest version!
package com.github.antelopeframework.spring.config;
import java.util.Properties;
import lombok.Setter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
/**
* 将{@link PropertiesFactoryBean}加载的配置项输出出来, 用以检查环境是否正确配置.
*
* @author yangzhi
*
*/
public class PropertiesPrinter implements InitializingBean {
@Setter
private Properties properties;
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("Configed Properties: ");
printProperties(properties);
System.out.println("System Properties: ");
printProperties(System.getProperties());
}
private void printProperties(Properties properties) {
System.out.format("%32s %-16s\n", "-----key------", "--------value---------");
for (Object key : properties.keySet()) {
System.out.format("%32s %-16s\n", key, properties.getProperty(key.toString()));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy