Maven3.0 配置和简单使用


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 的下载地址:请点这里

Maven 3.1.0 发布,项目构建工具

Linux 安装 Maven

Maven3.0 配置和简单使用

Ubuntu下搭建sun-jdk和Maven2

Maven使用入门

  • 1
  • 2
  • 下一页

相关内容