Spring Boot Application Annotation

I have been working a lot with Spring Boot lately so you may see a flood of posts from me on the subject (you have been warned). If you are looking at older example and create new projects you may have come across the Spring Boot Application Annotation. If you create a simple project your main class might look something like this.

The Spring Boot Application Annotation is a convenience annotation that adds all of the following:

  • @Configuration tags the class as a source of bean definitions for the application context.
  • @EnableAutoConfiguration tells Spring Boot to start adding beans based on class path settings, other beans, and various property settings.
  • @ComponentScan tells Spring to look for other components, configurations, and services in the the com.therealdanvega package.

If those 3 annotations look familiar to you its because the new annotation is the same as using those 3. It became so common to have to use those 3 on the main application class that they created the new one. It is perfectly fine to put the other 3 back especially if you get into a situation where you need to pass arguments to one of the annotations. In the following example I moved the 3 annotations back and customized the component scan to search 2 different packages instead of just the current one.

If you cntrl + click (cmd+click on the mac) on the Spring Boot Application Annotation you will be taken to the class definition of that so you can see exactly what is going on there.


Hi, I’m Dan Vega. I am a Software Engineer living just outside of one of my favorite places in the world, Cleveland, Ohio. I am a self-taught programmer who firmly believes that you can accomplish anything in this life if you put your mind to it, roll up your sleeves and are willing to put in the work.

I have been writing software for over 18+ years now and I use my knowledge, passion, and influence to help other developers achieve their goals. I teach online and currently, have over 30,000 students.

When I am not writing software, I have a number of things that really keep me busy. I love to read books, listen to podcasts and watch online courses. I have a real thirst for knowledge and it consumes me every single day of the week. I also love to run & lift heavy weights which keep me balanced throughout the week.

Please note: I reserve the right to delete comments that are offensive or off-topic.