在controller中使用@Value无法获取到值,并且@Autowired也无法注入
@Value("${centerInfo.url}")
private String centerInfoUrl;
@Value("${proxy.url}")
private String proxyUrl;
@Autowired
private SysConsumerLogService sysConsumerLogService;
解决:controller中添加
public String getCenterInfoUrl() {
return centerInfoUrl;
}
public String getProxyUrl() {
return proxyUrl;
}
@Autowired
public SysConsumerLogController(SysConsumerLogService sysConsumerLogService) {
this.sysConsumerLogService = sysConsumerLogService;
}
使用参数时直接用getCenterInfoUrl()获取