I have some servlets and some websocket servlets in my java application.
I use latest stable spring framework.
what I know is that because the servlets are not called by a different bean so they are not injectable and I need to get the applicationContext and use getBean to get the required objects.
is it true?
or can I use @Autowired in servlets somehow ?
so I want to be able to do the following:
@ServerEndpoint(value="/ServConnect")
public class ServConnect {
@Autowired UserDb userDb;
Instead of
@ServerEndpoint(value="/ServConnect")
public class ServConnect {
UserDb userDb;
public void ServConnect() {
// get application context somehow
userDb = appCtx.getBean("userDb");
}
thank you