`

maven及物依赖Transitive dependencies

    博客分类:
  • JAVA
阅读更多

One of the highlights of Maven 2 is transitive dependency management. If you have ever used a tool like urpmi on a Linux box, you'll know what transitive dependencies are. With Maven 1, you have to declare each and every JAR that will be needed, directly or indirectly, by your application. For example, can you list the JARs needed by a Hibernate application? With Maven 2, you don't have to. You just tell Maven which libraries you need, and Maven will take care of the libraries that your libraries need (and so on).

Maven 2 的一大亮点就是及物依赖管理。如果你使用过象 Linux 平台上的 urpmi 的工具,你会知道什么是及物依赖。在 Maven 1 中,你必须声明你所需要的每个应用程序直接或者间接需要的 JAR 。比如, Hibernate 应用程序所需的 JARs 就有很多。在 Maven 2 中,你不必如此,你只要告诉 Maven 你所需要的库, Maven 会照顾到你的库所需要的库。

Suppose you want to use Hibernate in your project. You would simply add a new dependency to the dependencies section in pom.xml, as follows:

假设你在项目中需要使用 Hibernate ,你只要简单的在 pom.xml 文件的 dependencies 节中加入一个新的 dependency ,如下所示:

<dependency>
       <groupId>hibernate</groupId>
       <artifactId>hibernate</artifactId>
       <version>3.0.3</version>
       <scope>compile</scope>
   </dependency>

And that's it! You don't have to hunt around to know in which other JARs (and in which versions) you need to run Hibernate 3.0.3; Maven will do it for you!

这就够了!你不必知道运行 Hibernate 3.0.3 需要哪些 JARs ,以及它们的版本, Maven 会为你做这些工作!

The XML structure for dependencies in Maven 2 is similar to the one used in Maven 1. The main difference is the scope tag, which is explained in the following section.

分享到:
评论

相关推荐

    Apache Maven Dependency Management

    Manage your Java and JEE project dependencies with ease with this hands-on guide to Maven Overview Improve your productivity by efficiently managing dependencies. Learn how to detect and fix ...

    Maven权威指南 很精典的学习教程,比ANT更好用

    Transitive Dependencies, Project Attachments, and Project Artifacts 12.5.4.6. Advanced Unpacking Options 12.5.4.7. Summarizing Dependency Sets 12.5.5. moduleSets Sections 12.5.5.1. Module ...

    maven-ant-tasks-2.1.3-src

    Dependency management - including transitive dependencies, scope recognition and SNAPSHOT handling Artifact deployment - deployment to a Maven repository (file integrated, other with extensions) POM ...

    maven-ant-tasks-2.1.3

    Dependency management - including transitive dependencies, scope recognition and SNAPSHOT handling Artifact deployment - deployment to a Maven repository (file integrated, other with extensions) POM ...

    Android代码-基于touchevent的动画对象

    OffsetAnimator OffsetAnimator lets animate objects basing on touchevents, so users can be engaged in an animation process. ...The library doesn't have any transitive dependencies. Tutorial A

    apache-maven-3.0.2-bin

    * [MNG-4913] - [regression] User properties override equally named POM properties of transitive dependencies * [MNG-4915] - Versions in pom.xml are not checked for invalid characters * [MNG-4918] -...

    LootTables:Kotlin DSL,用于在Minecraft Forge mods中创建战利品表

    战利品表 Kotlin DSL,用于在Minecraft Forge mod中创建战利品表。 有关文档和使用说明,请查看 。... transitive = false }) } Gradle/科特琳 repositories { maven(url = " https://jitpack.io " ) }

    Android代码-登录与注册页面的MD风格

    MaterialLogin A material-designed login (and register) view Download Grab via Gradle: ...or Maven: ... material-login ...You should also add CircularReveal lib for 2.3 support- first add remote ... transitive

    spring 最新框架jar

    use Maven or other transitive dependency management tools? See [building a distribution with dependencies][]. ## Documentation See the current [Javadoc][] and [reference docs][]. ## Getting Support ...

Global site tag (gtag.js) - Google Analytics