Maven : what is the “runtime” scope purpose? [duplicate]

runtime is useful for dependencies required for unit tests and at runtime, but not at compile time. This may typically be dynamically loaded code, such as JDBC drivers, which are not directly referenced in the program code.

Setting dependency to provided ensure that there isn’t an accidental dependency on the code, and also keeps the dependency from being transitive. So that, for example, if module A has a provided dependency on library X, and module B depends on module A, it does not inherit the dependency on library X. Using “runtime” or “compile” would cause B to depend on X.

Leave a Comment