当前位置:网站首页>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 .
边栏推荐
- JMeter use case
- 【招聘】[北京中关村/远程][TensorBase][开源数据仓库]等一群人,做一件事
- NLog自定义Target之MQTT
- JSP learning (2) -- JSP script elements and instructions
- Jsp Learning (2) - - jsp script Elements and instructions
- Hydra installation and use
- In case of default import failure
- Docker 之MySQL 重启,提示Error response from daemon: driver failed programming external connectivity on **
- mysql服务器启动后自动停止
- 视频会议时听不到声音该如何处理?
猜你喜欢
![Web technology sharing | [Gaode map] to realize customized track playback](/img/0b/25fc8967f5cc2cea626e0b3f2b7594.png)
Web technology sharing | [Gaode map] to realize customized track playback

MTLs guidelines for kubernetes engineers

STM32通过DMA进行ADC采集(HAL库)

华为云招募工业智能领域合作伙伴,强力扶持+商业变现

Qt筆記-QMap自定義鍵(key)

关于#数据库#的问题,如何解决?

系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式

以小见大:一个领域建模的简单示例,理解“领域驱动”。

In the era of video explosion, who is supporting the high-speed operation of video ecological network?

Read Apache shardingsphere
随机推荐
Spark and mysql:did not find registered driver with class com mysql. jdbc. Driver
Is flush easy to open an account? Is it safe to open an account online?
图计算Hama-BSP模型的运行流程
Analysis of the writer source code of spark shuffle
Unable to connect after win10 WiFi is disconnected
. NETCORE enables image scaling and cropping - based on imagesharp
Examples of MySQL account addition, deletion, modification, data import and export commands
UI自动化定位利器-xpath实战
What is a flush? Is online account opening safe?
web技术分享| 【高德地图】实现自定义的轨迹回放
High availability ResourceManager
Blazor University (31)表单 —— 验证
Spark streaming receiver startup and data receiving
Spark Streaming-Receiver启动和数据接收
mysql5.7.27安装之windows8.1 64
In the era of video explosion, who is supporting the high-speed operation of video ecological network?
使用 POST 向 ASP.NET Core 传递数据时的长度限制与解决方案
jsp学习之(三)--------- jsp隐式对象
Hello Playwright:(7)模拟键盘和鼠标
Windows8.1 64 installed by mysql5.7.27