springboot工具类注入service 类
@Component
public class FileUtils {
@Autowired
private PropertiesUtil properties;
@Autowired
private INewsInfoTableService newInfoService;
private static INewsInfoTableService newInfoServiceinfo;
@PostConstruct
public void init() {
newInfoServiceinfo = newInfoService;
}
@Component
public class FileUtils {
private static INewsInfoTableService newInfoServiceinfo;
@Autowired
public void init(INewsInfoTableService newInfoService) {
FileUtils.newInfoServiceinfo = newInfoService;
}
也可以写成上面一种模式
springboot 工具类 获取属性文件application.properties 属性值,
private static String fileServerAddress;
@Autowired
public void init2(Environment env) {
fileServerAddress = env.getProperty("citydo.fileServerAddress");
}