Spring: How do I switch off a bean?

Learn
Aug 29, 2024

--

I have a spring boot application with all kinds of beans in it, each of which takes a bunch of time to initialized, and there is one bean that I am actually interested in coding again. How do I turn OFF the other beans?

Using the @ConditionOnExpression annotation.
Just set the value as false.

@ConditionOnExpression(value = “false)
BeanIDontCareAbout

I did that for about five beans and easily saved at least five minutes of start up and less logs to scroll.

--

--

Learn
Learn

Written by Learn

On a continuing learning journey..

No responses yet