spring读取propertyes 新方法
<context:property-placeholder location="classpath:mysql.properties"/>
<util:properties id="settings" location="classpath:webConfig.properties"></util:properties>
Bean里要加入
xmlns:util="http://www.springframework.org/schema/util"
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
@Component("webConfig") public class WebConfig { @Value("#{settings['web.version']}") private String webVersion; public String getWebVersion() { return webVersion; } }
@Autowired private WebConfig webConfig; webConfig.getWebVersion();