I am relatively new to Java, as a JS dev, working on a SpringBoot application I see a pattern that peaked my curiosity:
Within the Application.java there are several import classes, which are then marked exclude within @SpringBootApplication, eg
import org.springframework.boot.autoconfigure.data.database.DataBaseAutoConfiguration;
...
@SpringBootApplication(
exclude = {DataBaseAutoConfiguration.class, ...}
)
DataBaseAutoConfiguration is not referenced anyplace else in the codebase, except here.
Can someone explain the purpose of this pattern? It feels odd to import the class then immediately exclude it in the configuration
Why not have something like:
exclude = {"DataBaseAutoConfiguration", ...} then lookup the class to ignore within Spring, avoiding the apparent "useless" import?
or:
// import nothing
@SpringBootApplication