properties文件使用{0}...

例如properties文件的配置

weixin.token.url=https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}

java文件中可以写成:

/**
* 微信Token请求接口地址
*/
@Value("${weixin.token.url}")
private String tokenUrl;

String address = MessageFormat.format(tokenUrl, appId, secret);

MessageFormat类来拼接

原文地址:https://www.cnblogs.com/muliu/p/6179470.html