数据大屏项目采坑01 (已解决)
- 在做工地是数据大屏项目的时候,我们采用的技术是微服务,需要springboot与redis、zookeeper、dubbo等相结合
在开发过程中遇到了空指针异常,报错信息具体如下:
2022-03-02 13:12:53.530 ERROR 71824 --- [nio-8090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at com.qf.bigdata.view.web.service.impl.WorkerTotalServiceImpl.workerTotal(WorkerTotalServiceImpl.java:21) ~[classes/:na]
at com.qf.bigdata.view.web.controller.api.WorkerController.getWorkerTotal(WorkerController.java:19) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_301]
......
解决
step01
服务提供者的@Service是来自dubbo的Service,而不是springframework中的
step02
服务消费者的@Reference是来自dubbo的
step03
启动类要记得加@EnableDubbo
---------小插曲----------------------
当上述步骤全都做完之后,我发现报了一个新错,此时我很开心那,因为上面的问题就算是解决了,下面是新的错误信息
org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.100.107:6379
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1534) ~[spring-data-redis-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1442) ~[spring-data-redis-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1228) ~[spring-data-redis-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1211) ~[spring-data-redis-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:975) ~[spring-data-redis-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:360) ~[spring-data-redis-2.3.6.RELEASE.jar:2.3.