3.1 下载Maven并编译实例源码

3.1 Downloading Maven and compiling the examples

3.1 下载Maven并编译实例源码

 

Here are the steps to download and install Maven:

1 Download Maven from the Apache Software Foundation: http://maven.

apache.org/.

Maven is provided in both tarball and zip format, depending on your operating

system.

2 Expand the downloaded archive to a permanent location on your computer.

3 Create an environment variable named M2_HOME that points to the Maven

directory.

4 On Unix, add the $M2_HOME/bin directory to the PATH environment variable

(on Windows, add the %M2_HOME%\bin directory to the %PATH% environment

variable).

5 Verify the Maven installation by running the following command from the command

line:

$ mvn -version

Apache Maven 2.2.1 (r801777; 2009-08-06 13:16:01-0600)

Java version: 1.5.0_19

Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/

Home

Default locale: en_US, platform encoding: MacRoman

OS name: "mac os x" version: "10.6.2" arch: "i386" Family: "unix"

 

下面是下载和安装Maven的步骤:

1. 从Apache Software Foundation下载Maven:http://maven.apache.org/.

2. 解压下载的压缩文件到本地一个目录.

3. 创建环境变量M2_HOME指向Maven的目录

4. 如果使用Unix系统,需要添加$M2_HOME/bin目录到PATH环境变量(

   windows系统,添加%M2_HOME%\bin到%PATH%环境变量).

5. 使用下面的命令行命令,检查Maven的安装是否成功:

   mvn -version

   Apache Maven 2.2.1 (r801777; 2009-08-06 13:16:01-0600)

  Java version: 1.5.0_19

  Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/

  Home

  Default locale: en_US, platform encoding: MacRoman

  OS name: "mac os x" version: "10.6.2" arch: "i386" Family: "unix"

 

You should see similar output which indicates that Maven is properly installed.

If you don’t see similar output, you’ll need to rectify this before proceeding. See

the Maven installation instructions for more information: http://

maven.apache.org/download.html#Installation.

输入命令mvn -version后,你应该看到类似的指示Maven已经成功安装的输出信息.如果没

看到类似的输出信息,你需要正确安装Maven然后再继续下面的内.参考Maven安装知道,以

获取更多信息.

 

YOU NEED AN INTERNET CONNECTION To use the examples in this book, you’ll

need a broadband connection to the Internet. This is so that Maven can

download the necessary dependencies for the examples.

 

要使用本书的例子,你还需要因特网的宽带连接.因为Maven需要下载必要依赖包.

 

If you’ve successfully installed Maven, the examples need to be unzipped and compiled.

After expanding the zip file containing the example source code, you’ll be ready

to compile the examples. To do so, move into the amq-in-action-example-src directory

and run the command shown next. For the convenience of recognizing the actual

command apart from the rest of the output, the command itself is listed in bold.

 

如果你已经成功安装Maven,可以解压和编译本书实例.解压zip文件,得到实例的源代码后即可编译.

为此,在命令行中进入amq-in-action-example-src目录,执行下面的命令.为了区分命令本身和命令的

输出,命令字符以粗体字显示.

 

[amq-in-action-example-src] $ mvn clean install

[INFO] Scanning for projects...

[INFO] -------------------------------------------------------------------

-----

[INFO] Building ActiveMQ in Action Examples

[INFO] task-segment: [clean, install]

[INFO] -------------------------------------------------------------------

-----

Downloading: http://localhost:8081/nexus/content/groups/public/org/apache/

maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom

3K downloaded (maven-clean-plugin-2.2.pom)

...

[INFO] [install:install {execution: default-install}]

[INFO] Installing /private/tmp/amq-in-action-example-src/target/

activemq-in-action-examples.jar to /Users/bsnyder/.m2/repository/org/

apache/activemq/book/activemq-in-action-examples/1.0-SNAPSHOT/

activemq-in-action-examples-1.0-SNAPSHOT.jar

[INFO] Installing /private/tmp/amq-in-action-example-src/target/

activemq-in-action-examples-src.zip to /Users/bsnyder/.m2/repository/org/

apache/activemq/book/activemq-in-action-examples/1.0-SNAPSHOT/

activemq-in-action-examples-1.0-SNAPSHOT-src.zip

[INFO] -------------------------------------------------------------------

-----

[INFO] BUILD SUCCESSFUL

[INFO] -------------------------------------------------------------------

-----

[INFO] Total time: 57 seconds

[INFO] Finished at: Fri Dec 04 22:35:57 MST 2009

[INFO] Final Memory: 24M/44M

[INFO] -------------------------------------------------------------------

-----

Much of the output from the compilation of the examples has been elided for brevity.

Suffice it to say that this output represents a successful compilation. As long as you see

the BUILD SUCCESSFUL message, you’re ready to move on to the next section. If, on

the other hand, you see the BUILD FAILURE message, you’ll need to troubleshoot and

correct the situation before proceeding.

 

为简单起见,大部分编译时的输出都被省略了.类似上面的输出来自一个成功的编译.只要你看到

BUILD SUCCESSFUL,你可以继续看下一节内容.如果看到BUILD FAILURE,你需要找出编译失败的

原因然后再继续下一章节.

 

译注: 关于本书的源码及其编译,请看: http://jackyin5918.iteye.com/blog/1945209

你可能感兴趣的:(maven)