Correct way to declare multiple scope for Maven dependency?

前端 未结 4 1777
离开以前
离开以前 2021-02-03 17:05

I have a dependency that I want to use in test scope (so that it is in the classpath when I am running unit tests), and in runtime scope (so that I can

4条回答
  •  长情又很酷
    2021-02-03 17:27

    Declaring a dependency with a scope of runtime ensures that the library is not available during compile time.

    Declaring the dependency as optional causes a break in the dependency resolution process; projects depending on your libraries will need to explicitly include the dependencies themselves.

    So the correct way to declare this would be:

    
      org.slf4j
      jcl-over-slf4j
      1.7.13
      runtime
      true
    
    

提交回复
热议问题