Search code examples
javaspringspring-bootmavenspring-boot-starter

Should stable project still use spring-boot-starter-*?


There are many Maven artifacts named spring-boot-starter-*. As the names imply, they are very useful for an application project to get started with Spring Boot.

However, after the application project become stable, should it keep using these spring-boot-starter-*?

My concern is that doing so uses the Maven mechanism of "transitive dependencies", and it seems to violate the suggestion in Maven documentation:

Although transitive dependencies can implicitly include desired dependencies, it is a good practice to explicitly specify the dependencies you are directly using in your own source code.

For example, suppose an application project directly uses the Spring annotation @EventListener. The annotation is in the Maven artifact spring-context, and spring-context is included in spring-boot-starter. Should the application project directly specify the dependency on spring-context after it become stable?


Solution

  • The Spring Boot starter artifacts are just a shorthand for including several Spring Boot artifacts at once. My company has services in production that use starter artifacts. Of course, you could replace each starter with a list of the artifacts it contains, but I think the Maven suggestion is more about unrelated transitive dependencies, such as if your application inherited Guava from some JSON library as a transitive dependency.

    When the transitive dependencies all come from the same source and are designed to work together, I don't think it's a problem. At least, I don't see it as such.