У меня есть следующая ошибка, когда я пытаюсь получить доступ к главной странице < /p>
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userJpaRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'net.codejava.spring.repository.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userJpaRepository)}
< /code>
В моем usercontroller у меня есть следующий код < /p>
@Controller
public class UserController {
private UserService employeeServiceImpl;
@RequestMapping("/")
public String employee() {
this.employeeServiceImpl.listAlUsers();
return "employee";
}
@Autowired(required = true)
public void setEmployeeService(UserService employeeServiceImpl) {
this.employeeServiceImpl = employeeServiceImpl;
}
}
< /code>
my userservice < /p>
public interface UserService {
public abstract List listAlUsers();
public abstract User addUser(User user);
public abstract int removeUser(int id);
public abstract User updateUser(User user);
}
< /code>
my userserviceimpl < /p>
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
@Qualifier("userJpaRepository")
private UserRepository userJpaRepository;
@Override
public List listAlUsers() {
return userJpaRepository.findAll();
}
@Override
public User addUser(User user) {
return userJpaRepository.save(user);
}
@Override
public int removeUser(int id) {
userJpaRepository.delete(id);
return 0;
}
@Override
public User updateUser(User user) {
return userJpaRepository.save(user);
}
}
< /code>
my jparepository < /p>
@Repository("userJpaRepository")
public interface UserRepository extends JpaRepository {
}
< /code>
web.xml
contextConfigLocation
/WEB-INF/spring/root-context.xml
org.springframework.web.context.ContextLoaderListener
appServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/spring/appServlet/servlet-context.xml
1
appServlet
/
< /code>
my servlet-context < /p>
/WEB-INF/views/
.jsp
messages
< /code>
Корн-контекст пуст. < /p>
Я не знаю, где есть возможная причина ошибки, я стараюсь найти варианты разнообразных, но если я использую рисунок DAO, я получаю одинаковую ошибку, поэтому я бы знал, что такое, чтобы попробовать его. Важно решить эту ситуацию. < /p>
С уважением! < /p>
Подробнее здесь: https://stackoverflow.com/questions/425 ... pressed-th
Ошибка Создание Bean с именем «Userservice»: неудовлетворенная зависимость, выраженная через поле «UserJparePository» ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение