Ошибка при создании bean-компонента с именем userService: неудовлетворенная зависимость, выраженная через поле userJpaReJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Ошибка при создании bean-компонента с именем userService: неудовлетворенная зависимость, выраженная через поле userJpaRe

Сообщение Anonymous »

При попытке доступа на главную страницу возникает следующая ошибка

Код: Выделить всё

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)}
В моем UserController у меня есть следующий код

Код: Выделить всё

@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;
}

}
Моя служба пользователей

Код: Выделить всё

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);
}
Мой UserServiceImpl

Код: Выделить всё

@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);
}
}
Мой репозиторий Jpa

Код: Выделить всё

@Repository("userJpaRepository")
public interface UserRepository extends JpaRepository {

}
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
/


Мой контекст сервлета

Код: Выделить всё

















/WEB-INF/views/


.jsp






messages





















Корневой контекст пуст.

Я не знаю, где возможная причина ошибки. попытайтесь найти разные варианты, но если я использую шаблон DAO, я получаю ту же ошибку, поэтому мне нужно знать, в чем проблема, чтобы попытаться ее решить.

конфигурация проекта выполнена в формате xml, но я думаю, что решать эту проблему не так уж и важно. ситуация.

С уважением!

Подробнее здесь: https://stackoverflow.com/questions/425 ... pressed-th
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»