file-> Settings – & gt; Editor-> Inspections click on the search bar to enter Spring Core
Spring Core -> Code -> The Autowring for Bean Class changes the Severity level from the previous error to warning, so that the idea will not report an error

2. If you can’t compile it, check to see if the package is not imported, or if it is injected as static type
In the Spring Framework, we cannot @Autowired static variable, create Spring beans, for example, without that:
@Autowired
private static YourClass yourClass;
Can have a try, yourClass in such a state can not be dependency injection, throws an exception during execution. Java lang. NullPointerException, why?Static variables/class variables are not properties of an object, but properties of a class. Spring is based on dependency injection at the object level.
The use of static variables/class variables extends the use of static methods. Static methods are not recommended in Spring. The main purpose of Dependency Injection is to allow the container to generate instances of an object and then use them throughout the life cycle, while also making testing easier.
Once you use static methods, you no longer need to generate instances of the class, which makes testing more difficult, and you can’t generate multiple instances with different dependencies for a given class using injection methods. This static field is an implicit shared static field. It is a global state. Spring also does not recommend this.
Read More:
- Springboot error: property ‘sqlsessionfactory’ or ‘sqlsessiontemplate’ are required error details
- @Detailed description and code demonstration of qualifier
- Field userrepository in com.example.demo2.service.imp.UserServiceImp required a bean of type ‘com.ex
- Springboot project startup exception – required a single bean, but 2 were found
- Spring boot project running error: Servlet.service () for servlet [dispatcherServlet] threw exception
- Using global timing task cronutil in hutool tool class
- Solve the interceptor calling service layer to display null pointer.
- non-static variable this cannot be referenced from a static context
- error: invalid use of non-static member function
- Initialization order of Java objects
- Springboot integrated with mybatis
- Spring MVC 406 status code / could not find acceptable representation
- Abstract precautions
- Elasticsearch in Spring uses Spel to dynamically create Index of Documet class
- Spring integrates JUnit configuration
- C ා programming encountered an object reference is required for the non-static field, method, or property error
- The spring boot project was first created, pom.xml The error is Maven configuration problem. How to solve it?
- The difference between sleep() and wait() in Java
- How to realize automatic assembly in springboot
- Realization of springboot authorization verification technology based on JWT