I am trying to make a non-xml configuration for a simple Java application. Here are my files: This is my servlet:
package com.abcd.noxml;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@WebServlet("/Ctrlr")
public class Ctrlr extends HttpServlet {
    @Autowired TeaService teaService;
    private static final long serialVersionUID = 1L;
    public Ctrlr() {
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws  {
        String brand = request.getParameter("brand");
        teaService.teaServe(brand);
    }
}
and this is the jsp I have
<body>
<form action="Ctrlr" method="POST">
    <input type="text" name="brand" />
    <input type="submit" value="submit" />
</form>
</body>
this is my configuration file
package com.abcd.noxml;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
    @Autowired
    TeaService teaService;
    @Bean
    public TeaService teaService()
    {
        return new TeaServiceImpl();
    }
}
When I try to create a bean with @Autowire in my servlet, it is returning null. Please suggest how can this be solved. Redirect me to the existing links if this is a repeat question. Thank you
 
    