Olá amigos, estou com uma aplicação que utiliza o spring.
Tenho o meu applicationContext.xml localizado no WEB-INF e está todo configurado.
<context:component-scan base-package="br.com.teste"
annotation-config="true" />
E no web.xml possuo as linhas:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Minhas classes estão anotadas. Exem: ClienteDAOImpl com o @Repository -> ClienteBOImpl com o @Component -> ClienteService com o @Service -> ClienteAction com o @Component;
Estou dando um:
@Autowired
private ClienteService clienteService;
Mas ele vem nulo.
Caso eu não utilize o @Autorired e fizer assim:
appContext = new ClassPathXmlApplicationContext(
"applicationContext.xml");
clienteService = (ClienteService) appContext.getBean("ClienteService");
Ele funciona.