Maven Basics

I assumed that you have correctly installed and configured Java Development Kit.

First, you should download apache maven from this page: https://maven.apache.org/download.cgi.

There are several kinds of files for you. I choosed the binary zip archive, and unzipped the file under the directory: D:\Program Files\apache-maven-3.3.9:


Then right click on your computer as below, and choose the menu "属性".


Then go through the following steps, when you are at step 4, type the path of bin in your unzipped maven directory (for me, it is "D:\Program Files\apache-maven-3.3.9\bin") to the end of value.


Save and exit, open cmd.exe and type "mvn -v" to test whether you have installed and configured maven correctly.

Create a folder for test purpose: D:\java_test.

In cmd, change to the directory: D:\java_test which you just created. Type:

mvn archetype:generate -DgroupId=com.mycompany.helloworld -DartifactId=helloworld -Dpackage=com.mycompany.helloworld -Dversion=1.0-SNAPSHOT

Wait, and when you are asked to "Choose a number", type106.

Wait, and when you are asked to confirm Yes, type enter button.

Wait until the process is over, and refresh your D:\java_test directory, you will see a new folder named "helloworld" whose directory structure is as below:


Open App.java and AppTest.java, in top lines of these two file, revise package name to be com.mycompany.helloworld as below:



Open pom.xml and revise values of groupId, artifactId and version as below:


Then in cmd, change directory to be under the helloworld directory, and then type mvn package as bellow:


You can then find a new folder created:


In cmd, type:

java -cp target/helloworld-1.0-SNAPSHOT.jar com.mycompany.helloworld.App

and you will see:


Yes, "Hello World!" was printed to the screen.

Back to the file App.java, and you will know where this output is from:


That's all, bye.

by Yakima Teng on February 24, 2016 in Shanghai.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值