1、追加rf.properties
#設備信息同步地址
#測試環境
synchronization.pos_url.anchor: http://xx.xx.xx.xx:8080/jndjplatform_api/api/tongyuan/getAnchorInfo
synchronization.pos_url.tag: http://xx.xx.xx.xx:8080/jndjplatform_api/api/tongyuan/getTSTagBeaconData
synchronization.pos_url.call: http://xx.xx.xx.xx:8080/jndjplatform_api/api/tongyuan/getTBDeviceInfo
2、追加配置文件的config類,把配置信息加載上來
package com.jndj.platform.common.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Component
@PropertySource(value = "classpath:rf.properties")
@Data
public class RfConfig {
@Value("${synchronization.pos_url.anchor}")
private String anchor;
@Value("${synchronization.pos_url.tag}")
private String tag;
@Value("${synchronization.pos_url.call}")
private String call;
}
3、想用的地方,直接注入config類,直接使用即可
@Autowired
RfConfig rfConfig;
// 通過接口,獲得最新的設備設備
HttpRequest httpRequest = new HttpRequest(rfConfig.getAnchor());
String unitResult = httpRequest.post();