工具类注入Service
来源:互联网 发布:子域名是否需要备案 编辑:程序博客网 时间:2024/05/23 18:31
工具类使用注解注入Service
静态工具类注入
1、在spring自动扫描包设置中将工具类所在的包加进来
代码:
@Componentpublic class TestUtil { @Resource private TEStationService stationService; private static TestUtil testUtil; @PostConstruct public void init() { testUtil = this; } public static void addAdmin(String phone, String openid,int role) { switch (role) { case 1: System.out.println("hahahahhahahh"); testUtil.stationService.updateAdmin(phone, openid); break; default: break; } }}
非静态工具类注入
@Componentpublic class Test1 { @Resource private TEStationService stationService; private static Test1 testUtil; @PostConstruct public void init() { testUtil = this; } public void addAdmin() { System.out.println("hahahahhahahh"); testUtil.stationService.updateAdmin("123123", "qweqwe"); }}
阅读全文
0 0
- 工具类注入Service
- spring 工具类注入Service方法
- 静态工具类注入service的方法
- java 静态工具类中注入service
- java工具类中注入service,dao类
- 静态工具类中使用注解注入service
- 静态工具类中使用注解注入service
- spring 通过中间层工具类SpringBeanFactoryUtils 实现service 注入
- 如何在utils工具类中注入mapper service
- 静态工具类中使用注解注入service
- 静态工具类中使用注解注入service 空指针
- jsp页面中静态方法调用使用service的类,注入静态工具类使用service
- Spring注入service为null另类解决办法 工具类 一般类 静态 非controller
- Spring注入service为null另类解决办法 工具类 一般类 静态 非controller
- SSM环境下普通工具类中调用@Autowired注入的service
- springmvc+mybatis service注入问题 找不到注入的类
- 4 @Autowired不能注入,要注入的类已经@Service
- spring的实例类注入service注解
- vue组件
- HDU 1241 Oil Deposits【深搜练习】
- 文章标题
- UVa 202 Repeating Decimals 循环节
- 关于位运算(转需)
- 工具类注入Service
- 微信二次分享解决方案
- 做乘法
- JVM调优总结 -Xms -Xmx -Xmn -Xss
- Python基础之语句(条件、循环)
- Design Compiler基础知识整理
- 面向对面
- 编写一个JFrame窗口,要求如下: 1. 在窗口的NORTH区放置一个JPanel面板。 2. JPanel面板放置如下组件: (1) JLable标签,标签文本为“兴趣”,右边接着是三个JChec
- 并查集(最小生成树)