maven及物依赖Transitive dependencies

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值