我从TomCat收到一些错误请帮助..
org.springframework.beans.factory.UnsatisfiedDependencyException:使用名称' userController创建bean的错误':通过字段' userService' 表达的不满意的依赖关系嵌套异常是org.springframework.beans.factory.UnsatisfiedDependencyException: 使用名称' userServiceImpl'创建bean时出错:通过字段“userDao' 表示的不满意的依赖关系;嵌套异常是org.springframework.beans.factory.BeanCreationException: 使用名称' userDAO'创建bean时出错:bean的初始化失败; 嵌套异常是java.lang.AbstractMethodError
我的UserDAO
package dao;
import entities.User;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserDAO extends CrudRepository<User, Integer> {
}
我的userserviceImpl
package service.impl;
import beans.UserBean;
import dao.UserDAO;
import entities.User;
import service.EntityBeanConverter;
import service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
@Service
@Transactional
public class UserServiceImpl implements UserService {
@Autowired
private UserDAO userDao;
@Autowired
private EntityBeanConverter converter;
@Override
public Iterable<UserBean> getAllUsers() {
Iterable<User> users = userDao.findAll();
List<UserBean> beanList = converter.convertToBeanList(users, UserBean.class);
return beanList;
}
@Override
public UserBean getUserById(Integer userId) {
Optional<User> user = userDao.findById(userId);
UserBean bean = converter.convertToBean(user, UserBean.class);
return bean;
}
@Override
public void saveUser(UserBean user) {
User userEntity = converter.convertToEntity(user, User.class);
userDao.save(userEntity);
}
@Override
public void deleteUser(Integer userId) {
userDao.deleteById(userId);
}
}
我的userController
package controller;
import beans.UserBean;
import service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
class UserController {
@Autowired
private UserService userService;
@RequestMapping("/users.html")
public ModelAndView showUsersPage() {
ModelAndView modelAndView = new ModelAndView("users");
return modelAndView;
}
@RequestMapping("/update-user.html")
public ModelAndView updateUser(@RequestParam(name = "user_id") Integer userId) {
ModelAndView modelAndView = new ModelAndView("users");
UserBean user = userService.getUserById(userId);
modelAndView.addObject("user", user);
return modelAndView;
}
@RequestMapping("/delete-user.html")
public ModelAndView deleteUser(@RequestParam(name = "user_id") Integer userId) {
userService.deleteUser(userId);
ModelAndView modelAndView = new ModelAndView("redirect:users.html");
return modelAndView;
}
@RequestMapping(value = "/save-user.html", method = RequestMethod.POST)
public ModelAndView saveUser(UserBean user) {
userService.saveUser(user);
ModelAndView modelAndView = new ModelAndView("redirect:users.html");
return modelAndView;
}
@ModelAttribute(name = "userList")
private Iterable<UserBean> getUserList() {
Iterable<UserBean> userList = userService.getAllUsers();
return userList;
}
@ModelAttribute(name = "user")
private UserBean getEmptyUser() {
return new UserBean();
}
}
我不知道在哪里可以找到我的错误问题,也许有人帮助我!