Здравствуйте. Помогите, пожалуйста, сложившиюся проблему.
Есть класс
public class UserServiceImpl implements UserService {
private UserDAO userDAO;
@Override
public void createEntity(User user) throws CustomDAOException {
if (!isUserExists(user)) {
userDAO.create(user);
} else System.out.println("User already exists");
}
Нужно чтобы при обращении к нему поднимался
private UserDAO userDAO; и так далее.
Делаю, как написанно в туториале.
@Service("userService") //Можно и @Component
public class UserServiceImpl implements UserService {
@Autowired
private UserDAO userDAO;
@Override
@Transactional
public void createEntity(User user) throws CustomDAOException {
if (!isUserExists(user)) {
userDAO.create(user);
} else System.out.println("User already exists");
}
Но тут же, при деплое, ловлю ошибки
[2016-09-25 01:48:32,906] Artifact newBD:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [operator.services.api.UserService]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [operator.services.api.UserService]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [operator.services.api.UserService]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}
Что я делаю не так?
UPD@Repository("userDAO")
public class UserDAOImpl extends GenericDAOImpl<User, Integer> implements UserDAO {
@PersistenceContext
private EntityManager entityManager;
@Override
public User getUserByNumber(String number) throws UserNotFoundException {
try {
Query query = entityManager.createQuery("select c.user from Contract c where c.number=:number")
.setParameter("number", number);
return (User) query.getSingleResult();
} catch (PersistenceException e) {
throw new UserNotFoundException("User " + number + " wasn't found", e);
}
}