简体   繁体   中英

Runtime dependency included in war

I am a little surprised: I declared a dependency in maven pom as runtime and it was still included in war. I honestly expected it not to do this... I used junit just for the purpose of demonstration...:) For example:


  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

Thanks, Roxana

Some maven-scopes:

  • if the dependency is needed in production and has to be delivered along with the application use scope runtime
  • if the dependency is needed only for (unit-)testing and should not be delivered use scope test
  • if the dependency is needed in production but is already part of the container (eg tomcat, JBOSS) use scope provided

If you want something at runtime then it has to be in the package. Otherwise where will the software know where to find it.

What were you expecting? And most importantly, why are you including JUnit in Runtime? It should be in test scope.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM