Correct way to declare multiple scope for Maven dependency?

前端 未结 4 1778
离开以前
离开以前 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:22

    You can only define one scope value per tag.

    I'm afraid what you'd like to do cannot be achieved by merely using a scope. If you define a scope of test, it will only be available during tests; if you define a scope of provided, that would mean that you would expect that dependency for your project to be resolved and used during both compilation and tests, but it will not be included in your WAR file. Either way, it's not what you would want.

    Therefore, I would recommend you have a look at the maven-assembly-plugin, with which you can achieve it, but it will still require some playing around.

提交回复
热议问题