1.将properties文件位置加到spring mvc的配置的文件(spring-mvc.xml)中,如下
<bean
id=
"placeholderConfig" class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<
property name=
"fileEncoding" value=
"UTF-8" />
<
property name=
"location" value=
"classpath:conf/http.properties" />
</bean>
2.http.properties配置文件
http.url=
192.168.1.10
http.port=
8086
3.Controller代码
@Value(
"${http.url}")
private String strUrl;
@Value(
"${http.port}")
private String strPort;
转载请注明原文地址: https://ju.6miu.com/read-1310175.html