背景:

  在调用阿里云隐私保护有一个通话记录的回执消息是一个消费线程队列,这个还别人告诉我的,因为我根本没有看出来哪里是个线程了,然后我就把它当成普通的代码拿到返回值以后然后插入数据库

可是我这边该加的都加了,引入的这个service它就是一直报空指针,气死我了

后面我解决不了就去找主管,主管和我说这个是个线程,你这样的注入肯定是不行的。然后就没了,很开心,最起码有思路了,知道怎么找解决方法了,然而各种百度,各种试还是不行。后面就去找有做过多线程的同事,然后同事给我了一个工具,把里面需要注入的东西改成自己的就好了,

@Service
public class MapperUtil {
@Autowired
public MoveCarService moveCarService;//改成自己的 private static SimpleDateFormat df =
new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 private int dueTime = 86400000; public static MapperUtil mapperUtil; // 关键2 public MapperUtil() {
} // 关键3
@PostConstruct
public void init() {
mapperUtil = this;
mapperUtil.moveCarService = this.moveCarService;//改成上面对应的
}
}

然后再调用即可

springboot项目 线程消费队列注入报错误空指针的更多相关文章

  1. springboot 项目中获取默认注入的序列化对象 ObjectMapper

    在 springboot 项目中使用 @SpringBootApplication 会自动标记 @EnableAutoConfiguration 在接口中经常需要使用时间类型,Date ,如果想要格式 ...

  2. springboot项目WEB-INF 目录 jsp页面报404

    我是跟着<深入浅出 Spring Boot 2.x>这本书学习的,在"初识Spring MVC"章节中,搭建项目,然后访问jsp页面时报错:Path with &quo ...

  3. STS插件创建springboot项目,pom第一行报unkown错误

    Description    Resource    Path    Location    TypeUnknown    pom.xml    /amq-provider    line 1     ...

  4. springboot项目启动,但是访问报404错误

    启动类Application上加了@ComponentScan(basePackages = {})这个注解导致controller扫描不到导致的,如果加了这个注解,springboot就不会扫描Ap ...

  5. springboot项目线程使用2

    线程处理的一个实际例子: @Service public class SynAsynThreadTestServiceImpl implements SynAsynThreadTestService ...

  6. Eclipse导入SpringBoot项目pom.xml第一行报错Unknown error

    1.网上搜的都说是将SpringBoot2.1.5版本降级到SpringBoot2.1.4版本,感觉这治标不治本啊,以后想升级不是玩完了. 错误如下所示: 参考:https://ask.csdn.ne ...

  7. springboot项目线程使用

    下面是一个demo: public class TestThread { private static int nThreads =Runtime.getRuntime().availableProc ...

  8. springboot项目POM文件第一行报错 Unknown Error

    改成 war 不错了,但是打包麻烦 pom 文件报错 UnKnown Error第一次碰到这个问题,花了几个小时才解决,除了UnKnown 没有任何提示.网上搜的大部分情况都不是我遇到的. 还是没有解 ...

  9. Springboot项目启动报错,提示Cannot determine embedded database driver class for database type NONE

    我在springboot项目里面引入了数据库的配置: <dependency> <groupId>org.mybatis.spring.boot</groupId> ...

随机推荐

  1. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 表格:精简表格

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  2. PaperReading20200220

    CanChen ggchen@mail.ustc.edu.cn Recently I am occupied with something else so today I am going to sh ...

  3. Linux和云供应商Red Hat被IBM以34亿美元的价格收购

    导读 今天的主题包括IBM以340亿美元收购Red Hat,人性化是使人工智能成功的关键.两家公司于10月28日宣布,IBM正以340亿美元的价格收购Linux和云技术供应商Red Hat,以期改变云 ...

  4. 如何解决ajax跨域请求?

    1.什么是跨域? a.域名不同 b.域名相同,端口不同 注:只有域名相同,端口相同时,才可以访问数据 可以使用jsonp解决ajax跨域请求的问题. 2.什么是jsonp? Jsonp其实就是一个跨域 ...

  5. jquery使用css函数设置背景色无效解决办法

    外部的css样式为: #imageArea{ width: 200px; height: 300px; background-color: #eee !important; } 通过 以下代码来修改其 ...

  6. Django 3.0 中连接mysql 8.0,可以不使用pymysql ,升级Mysqlclient即可

    python 中,连接mysql一般都推荐用pymysql ,而且在django中,网上的教程都是这么连接mysql的. import pymysql pymysql.install_as_MySQL ...

  7. [Verilog] indexed part-select +:

      That syntax is called an indexed part-select. The first term is the bit offset and the second term ...

  8. mysql里的序列应用详解

    相关知识库: MySQL知识库 相关文章: ibatis中主键的返回 oracle 实现自增auto_increament 用oracle的trigger生成主键的时候和hibernate冲突的讨论 ...

  9. Lesson 4 Seeing hands

    How did vera discover she had this gift of second sight? Several cases have been reported in Russia ...

  10. vue ref父子组件传值

    一. ref使用在父组件上 父组件html: <information ref='information'></information> import information ...