Reputation: 91
I know that when we annotate a java class as @SpringBootApplication
we will have internally annotations @EnableAutoConfiguration
and @SpringBootConfiguration
but i'm confused what is the difference between them.
I am very much new to spring boot, Can someone please elaborate on this.
Upvotes: 2
Views: 7938
Reputation: 529
it is meta annotation @SpringBootApplication will have other annotations
if @SpringBootApplication is not there applications need to use other annotations on Main class
Upvotes: 0
Reputation: 119
public @interface SpringBootConfiguration
Indicates that a class provides Spring Boot application @Configuration. Can be used as an alternative to the Spring's standard @Configuration annotation so that configuration can be found automatically (for example in tests).
from: SpringBootConfiguration docs
public @interface EnableAutoConfiguration
Enable auto-configuration of the Spring Application Context, attempting to guess and configure beans that you are likely to need.
from: EnableAutoConfiguration docs
So what is the difference?
@SpringBootConfiguration annotation tells us that a class is a configuration class, and @EnableAutoConfiguration automatically configures the Spring application based on its included jar files.
Upvotes: 4