Why were Spring Boot starter dependencies designed to be used contrary to the stated intent of Maven's transitive dependency mechanisms?

前端 未结 2 1941
孤街浪徒
孤街浪徒 2021-02-19 14:58

According to the Maven dependency documentation it is intended that all compile dependencies be explicitly listed, rather than transitively used at compile time:

2条回答
  •  无人共我
    2021-02-19 15:31

    This question was raised as an issue in the Spring Boot project as spring-boot#8341. Several Spring Boot developers responded to the issue to state their opinion that this is not actually a misuse of the Maven dependency mechanism.

    Comment:

    Why was the Spring Boot starter pattern was designed in such a way to be directly contrary to the intent of the underlying build system?

    IMO, you've read too much into a single sentence in Maven's docs. I think it's telling that to be even warned you have to opt in.

    Is there a reason it was felt that this misuse is "OK"?

    Misuse is rather subjective. I don't consider the starters to be a misuse. If you do, then you are free to declare all of your compile dependencies explicitly.

    Is there a "correct" way that this functionality — conveniently providing a set of dependencies at set known versions with a single simple Maven configuration — would better be implemented?

    I don't believe so, which could be one very good reason why transitive compile dependencies remain in the compile scope and no warnings are generated by default.

    Comment:

    You are overreading this and your point of view lack of practicability IMO. The dependency:analyze goal was a mean to offer users a way to detect that your compilation classpath only contains what you actually need. This sentence in the doc is merely there to explain why the compile scope is transitive as well.

    [...]

    In retrospective, you're having a Maven question and not a Spring Boot questions because tons of projects out there not using Spring Boot do not list all their compile dependencies themselves.

    Based on this feedback, ticket MDEP-557 has been created in for the Maven Dependency Plugin to not warn on these transitive dependency usage.

    So, to answer the question, the Spring Boot team feels this is an appropriate usage of transitive dependencies, and that it is that this is not contrary to the intent of Maven.

提交回复
热议问题