1. 网络请求访问路径:
server.port=8080
server.context-path=/demo-app
2. 获取header中的token:
@RequestHeader("token") String token
如:
@PostMapping("/saveApply")
public CommonResponse saveApply(@RequestBody ApplyRequest request, @RequestHeader("token") String token) {...}
3. 配置变量:
@Configuration
@ConfigurationProperties(prefix = "dev.test")
public class TestConfiguration {
private String host;
private String business;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getBusiness() {
return business;
}
public void setBusiness(String business) {
this.business = business;
}
}
application-local.properties配置文件中:
server.port=8080
server.context-path=/test-app
dev.test.host=http://xxx.xx.xxx.xxx:10018
dev.test.business=/test-app/business
使用:
@Autowired
private TestConfiguration testConfig;
testConfig.getHost();即可