mybatisplus测试类正常,在项目main方法下运行报错:Exception in thread "main" java.lang.NullPointerExcepti
测试类正常运行代码
@SpringBootTest
public class TEST {
@Autowired
private UserDao userDao;
@Test
void testGetAll(){
List<User> userList = userDao.selectList(null);
System.out.println(userList);
}
}
main方法中运行报错:Exception in thread "main" java.lang.NullPointerExcepti
public class Main {
@Autowired
private static UserDao userDao;
public static void main(String[] args) {
List<User> userList = userDao.selectList(null);
System.out.println(userList);
}
}
错误信息
at org.example.Main.main(Main.java:21)
进程已结束,退出代码1
求解