#spring对象注入失败
public class LogUtil {
@Autowired
private LogMapper logMapper;
public static final String INSERT = "insert";
public static final String DELETE = "delete";
public static final String UPDATE = "update";
public int insertLog(String userName, String type, String content, String invoker){
try{
Log log = new Log(userName, type, content, invoker);
log.preInsert();
return logMapper.insert(log);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
}
// 方法调用
LogUtil logutil = new LogUtil();
logutil.insertLog("xx","xx","xx","xx");
于是产生了空指针异常,因为LogMapper注