The controller jpa code normal
//controller class already annotation Resource method
@ RequestMapping ("/reg ")
Public String reg (it request, HttpServletResponse response, @ Valid the UserInfo backstageUser, BindingResult BindingResult) {
The UserInfo user=userDao. GetOne (1);
System. The out. Println (" system111: "+ user. GetName ());//here can normal to get the data
CommonUtil111 aa=new CommonUtil111 ();
Aa. Aa (request);//call the method will be an error
}
CommonUtil111
Public class CommonUtil111 {
@ the Resource
Public UserDao UserDao;
Public String aa (it request) {
The UserInfo w=userDao. GetOne (1);//there can not have been submitted to the Java lang. NullPointerException: null
System. The out. Println (" system444: "+ w.g etName ());
Return "";
}
}
UserDao
Public interface UserDao extends JpaRepository{
}
CodePudding user response:
What a great god help me see otherwise good trouble ahCodePudding user response:
Use the @autowired UserDao UserDaoCodePudding user response:
Null fault is still the sameCodePudding user response:
Know how to solve