原因:@Value并不会主动去父容器中查找配置文件属性值,你要配置或注入
所以用new的方式获取不到
用注入方式就获取到了
@Service
public class PropertyService {
@Value("${isc.app-id}")
private String iscAppid;
}
在controller注入:
@Autowired
private PropertyService propertyService;
isc:
app-id: 12121313456
参考:https://www.cnblogs.com/caoxs/p/9772193.html