歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Maven3.0 配置和簡單使用

Maven3.0 配置和簡單使用

日期:2017/2/28 14:50:10   编辑:Linux教程

Disc:maven能做什麼這裡就不浪費流量了,自己google一下什麼都有。這裡只是個簡單的入門,maven的文檔相當細致,這裡重復的過多也毫無意義,看完這篇能有個初步的認識就去看文檔吧

Context:Windows 7,maven3.0.5

Step:

1、安裝maven

1.1安裝maven(快速開始http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html)

2、創建maven項目

3、在jar文件中加入資源文件

1)在命令行輸入如下命令

C:\Users\Administrator\Desktop>mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=freecoop -DartifactId=FirstMvnApp

archetype:generate :創建項目原型

-DarchetypeArtifactId :利用maven提供的模板創建可取的值http://maven.apache.org/guides/introduction/introduction-to-archetypes.html中有說明

-DgroupId:這個是你的項目組Id到你本地的repository中看一下相對應的值就明白了

-DartifactId:項目名稱

系統會要求你輸入一個版面號,前面有個1.0-SNAPSHOT如果你什麼也不輸入這將作為默認的版本號,我們輸入1作為自己的第一個版本。

到這裡我們會看到在桌面上有一個FirstMvnApp工程,這就是我們用maven創建的第一個簡單工程。

在FirstMvnApp中有個pom.xml的文件用來表明這個maven項目。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>freecoop</groupId>
<artifactId>FirstMvnApp</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>FirstMvnApp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

目錄結構:

Maven 的詳細介紹:請點這裡
Maven 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved