您的位置:首页 > 其它

使用IDE与maven建立工程-1

2012-11-06 12:18 471 查看
一 、新建project



二、建立好的工程如下



.iml文件解释如下

GoalDescription
idea:cleanRemoves all existing IDEA files for the project.
idea:helpDisplay help information on maven-idea-plugin. Call
mvn idea:help -Ddetail=true -Dgoal=<goal-name>

to display parameter details.
idea:ideaGoal for generating IDEA files a POM. This plug-in provides the ability to generate project files (.ipr, .iml and .iws files) for IDEA.
idea:moduleCreates the module files (*.iml) for IntelliJ IDEA.
idea:projectCreates the project file (*.ipr) for IntelliJ IDEA.
idea:workspaceCreates the workspace file (*.iws) for IntelliJ IDEA.
刚建立好的工程中pom.xml的内容如下

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>

<groupId>testOne</groupId>
<artifactId>testOne</artifactId>
<version>1.0</version>
</project>


Ø project:pom.xml文件中的顶层元素;

Ø modelVersion:指明POM使用的对象模型的版本。这个值很少改动。

Ø groupId:指明创建项目的组织或者小组的唯一标识。GroupId是项目的关键标识,典型的,此标识以组织的完全限定名来定义。比如,org.apache.maven.plugins是所有Maven插件项目指定的groupId。

Ø artifactId:指明此项目产生的主要产品的基本名称。项目的主要产品通常为一个JAR文件。第二,象源代码包通常使用artifactId作为最后名称的一部分。典型的产品名称使用这个格式: <artifactId>- <version>. <extension>(比如:myapp-1.0.jar)。

Ø version:项目产品的版本号。Maven帮助你管理版本,可以经常看到SNAPSHOT这个版本,表明项目处于开发阶段。

Ø name:项目的显示名称,通常用于maven产生的文档中。

Ø url:指定项目站点,通常用于maven产生的文档中。

Ø description:描述此项目,通常用于maven产生的文档中。

对于一个项目中只有下面的一部分是是我们需要关注的:

<groupId>com.chongshi.test</groupId>

<artifactId>hello</artifactId>

<version>1.0</version>
三、新建一个java类
新建一个com.test.model.Hello.java

使用右边的 maven Project



第一次使用时一定要先使用clean 再使用compile

编译之后的文件目录如下,多出一个target文件夹

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: