Code directly
1. To create a serviceutils tool class, annotate it with @ Autowired
package com.deao.app.socket.netty.server.service.impl;
import com.deao.app.socket.netty.server.service.MessageService;
import com.deao.app.socket.netty.server.service.SocketGasExamArrangeManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class ServiceUtils {
@Autowired
public SocketGasExamArrangeManageService socketGasExamArrangeManageService;
@Autowired
public MessageService messageService;
public static ServiceUtils serviceUtils;
@PostConstruct
public void init() {
serviceUtils = this;
}
}
Used elsewhere
public static void main(String[] args) {
serviceUtils.socketGasExamArrangeManageService.selectGasExamArrangeManageByStudentId(studentId);
serviceUtils.messageService.message(null, request, account, null, true);
}
Read More:
- Realize the simplest recursive call, simulate exception in thread “main” java.lang.stackoverflowerror exception
- Use of HQL query.list () is a null pointer exception, but the database can find out the result
- How to handle exception in springboot
- About the error querying database. Cause: java.lang.nullpointerexception reported in mybatis
- The solution of using Autowired annotation to report errors in IntelliJ idea
- Solve the interceptor calling service layer to display null pointer.
- Solution of idea using @ Autowired annotation to report errors
- Solution of redisconnection factory in springboot2 not Autowired
- Method threw ‘java.lang.NullPointerException‘ exception. Cannot evaluate com.sun.proxy.xxx
- When the spring MVC project is running on idea, an error is reported when the controller is a null pointer
- Solution to null pointer error in array
- After the go pointer is declared and assigned, a panic: runtime error: invalid memory address or nil pointer reference appears
- How to deal with NullPointerException error in row.getlong in spark – sparksql
- Failed to get the resources path in the jar package, reporting an error null pointer
- Exception in thread “main“ java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to XXX
- Request processing failed;nested exception is java.lang.*
- How to use C + + function pointer array
- Error reporting: java.lang.nullpointerexception solution
- Exception handling of httpmessage notwritableexception in springboot
- Spring nested exception is java.lang.NoClassDefFoundError: org/springframework/core/MethodClassKey