//重点一:要加component注解 @Component public class LogUtil { @Autowired private YourService yourService; //重点二:建一个静态的本类 private static LogUtil logUtil; //重点三:初始化 @PostConstruct public void init() { logUtil= this; logUtil.yourService= this.yourService; } public static void update(Object object){ //你的业务逻辑 //重点四:service的调用 logUtil.yourService.save(object); }
怎样在工具类中注入service
猜你喜欢
转载自blog.csdn.net/lzg319/article/details/80755445
今日推荐
周排行