系统管理类--SystemEnvironmentManager
package com.mypack.core;import java.io.IOException;import java.util.Properties;import javax.annotation.PostConstruct;import org.springframework.core.io.Resource;import org.springframework.util.Assert;/** * * 系统管理类 * * @author Administrator * */public class SystemEnvironmentManager {private static Properties systemEnvironmentConfigProperties = new Properties();private Resource resource;@PostConstructpublic void init() {Assert.notNull(resource, "parameter resource is not null");readSystemEnvironmentConfigProperties();}private void readSystemEnvironmentConfigProperties() {try {systemEnvironmentConfigProperties.load(resource.getInputStream());} catch (IOException e) {throw new RuntimeException(e.getMessage(), e);}}public static String getProperty(String code) {if (code == null) {throw new IllegalArgumentException("parameter code is not null");}return systemEnvironmentConfigProperties.getProperty(code);}public Resource getResource() {return resource;}public void setResource(Resource resource) {this.resource = resource;}}
<bean id="systemEnvironmentManager"class="com.mypack.core.SystemEnvironmentManager"><property name="resource"value="classpath:system_environment_config.properties"></property></bean>