当前位置:网站首页>Service or mapper cannot be injected into a multithread
Service or mapper cannot be injected into a multithread
2022-06-22 17:06:00 【51CTO】
Multiple threads cannot be injected Service perhaps Mapper
1. Problems and causes
I wanted to realize log insertion through annotation ,
But the null pointer is always reported .
After a period of time, Baidu has tried ,
Finally, the debugging is successful .
2. Solution
2.1 Create a new tool class
import
org.
springframework.
beans.
BeansException;
import
org.
springframework.
context.
ApplicationContext;
import
org.
springframework.
context.
ApplicationContextAware;
/**
* class name: AppBean <BR>
* class description: please write your description <BR>
* @version 1.0 2019 year 4 month 2 Japan In the morning 10:03:10
* @author Aisino)Jack wei
*/
public
class
AppBean
implements
ApplicationContextAware {
private
static
ApplicationContext
applicationContext;
/**
* @Override
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) <BR>
* Method name: setApplicationContext <BR>
* Description: please write your description <BR>
* Remark: <BR>
* @param applicationContext
* @throws BeansException <BR>
*/
public
void
setApplicationContext(
ApplicationContext
appContext)
throws
BeansException {
applicationContext
=
appContext;
}
public
static
Object
getBean(
String
name){
return
applicationContext.
getBean(
name);
}
public
static
ApplicationContext
getApplicationContext() {
return
applicationContext;
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
2.2 The configuration file
stay Config Add one under the package Bean
Or in spring.xml Inside plus
Then add the following statement to the thread ,
Call again .
边栏推荐
- On the closure function of Scala
- Mqtt of NLog custom target
- NLog自定义Target之MQTT
- mysql服务器启动后自动停止
- MYSQL_ ERRNO : 1292 Truncated incorrect date value At add_ num :1
- Apache ShardingSphere 一文读懂
- scala-for推导:能够在for表达式中的最初部分定义值,并在(外面)后面的表达式中使用该值
- spark关于数据倾斜问题
- 新手必会的静态站点生成器——Gridsome
- Bidirectional data binding V-model and v-decorator
猜你喜欢

jMeter使用案例

高可用性的ResourceManager

【进阶自动化测试第一步】1分钟带你了解自动化测试
![[wechat applet to obtain the height of custom tabbar] is absolutely available!!!](/img/ed/7ff70178f03b50cb7bec349c1be5e0.png)
[wechat applet to obtain the height of custom tabbar] is absolutely available!!!

In case of default import failure
![[Alibaba cloud server - install MySQL version 5.6 and reinstall]](/img/5a/50b1de5f58235f6d11f6ad1eecc455.png)
[Alibaba cloud server - install MySQL version 5.6 and reinstall]

web技术分享| 【高德地图】实现自定义的轨迹回放

Mqtt of NLog custom target

UI自动化定位利器-xpath实战

JSP learning (2) -- JSP script elements and instructions
随机推荐
MySQL master-slave connection prompt of docker: communications link failure
Interface (optimization type annotation)
MySQL string field to floating point field
mysql账号增删改、数据导入导出命令举例
新手必会的静态站点生成器——Gridsome
Spark and mysql:did not find registered driver with class com mysql. jdbc. Driver
你管这破玩意儿叫高可用?
Figure operation flow of HAMA BSP Model
. NETCORE enables image scaling and cropping - based on imagesharp
scala-for的基本应用
The MySQL of docker restarts, prompting error response from daemon: driver failed programming external connectivity on**
The win10 desktop icon disappears and the toolbar turns black
JSP学习之开发模式
linux系统维护篇:mysql8.0.13源码下载及安装之“傻瓜式”操作步骤(linux-centos6.8)亲测可用系列
WPF效果第一百九十篇之再耍ListBox
vs2017 在调试状态不显示QString值的解决方法
[wechat applet to obtain the height of custom tabbar] is absolutely available!!!
MYSQL_ ERRNO : 1292 Truncated incorrect date value At add_ num :1
有同学问PHP要学什么框架?
web技术分享| 【高德地图】实现自定义的轨迹回放