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.

你可能感兴趣的:(maven,linux,Hibernate,xml,项目管理)