一:在工程中建立config.properties配置文件
#FTP的ip地址
address=192.168.25.133
#FTP的端口
port=21
二:在spring配置文件中配置加载上述的资源文件。(两种方式)
方式1:s
<context:property-placeholder location="classpath:config/*.properties"/>
方式2;
<bean id="propertyBean"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<array>
<value>classpath:config/*.properties</value>
</array>
</property>
</bean>
三:使用配置文件中配置的值
@Value("${address}")
private String ftpAddress;
这时ftp的地址直接就注入到ftpAddress中。