Properties配置获得参数;getClass().getResourceAsStream

在Spring-mvc.xml的配置为:

<bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>classpath*:*.properties</value> </list> </property> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="properties" ref="configProperties" /> </bean>

@Value("${batch.deal.merIds}") private String batchMerIds;

batchMerIds.properties文件里面:

batch.deal.merIds =800042016014598,800042016014595

batchMerIds = “800042016014598,800042016014595”;

String[] merIdsArray = StringUtils.split(batchMerIds ,",");

for(String merId : merIdsArray ){

}

InputStream inputStream = getClass().getResourceAsStream("/qdone/aps/test/alipay/总营支付宝扫码支付.json");

String content = IOUTils.toString(inputStream,CharEncoding.utf-8);

经验分享 程序员 微信小程序 职场和发展