Context and tomcat


#1

Marco,

I’m a little confused about the relationship between a spring ApplicationContext like AnnotationConfigApplicationContext (https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/AnnotationConfigApplicationContext.html) and tomcat.

I know I have to inject (or, set, rather) a context on my tomcat instance, but spring boot usually does this for me under the hood.

What is a context (is this a fancy name for bean factory or something?) and how does spring boot tell tomcat what the context is?

Thanks!


#2

That is because there really is no ‘relationship’ between these two. To make things very simple, yes, an applicationcontext is just that: a fancy name for a beanfactory.

Tomcat itself doesn’t care about that beanfactory. Or any other objects for that matter. Tomcat only cares about servlets and filters and that’s what your other question is about, which i’ll answer in the respective thread.