maven构建项目(maven命令)
来源:互联网 发布:返利机器人 知乎 编辑:程序博客网 时间:2024/05/12 19:06
1. maven2的安装(略)
2. 用maven创建myeclipse下的标准web项目
2.1 在命令行下,用maven创建一个web project
2. 用maven创建myeclipse下的标准web项目
2.1 在命令行下,用maven创建一个web project
1mvn archetype:create -DgroupId=net.selitech.ssim -DartifactId=ssim -DarchetypeArtifactId=maven-archetype-webapp
2.2 补全某些目录(命令行下切换到项目)
1cd ssh\src
2mkdir main\java
3mkdir test\resources
4mkdir test\java
2mkdir main\java
3mkdir test\resources
4mkdir test\java
2.3 打开项目,修改该pom.xml如下
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4 <groupId>net.selitech.ssim</groupId> <!--工程的组织或团队的唯一标识,并且这个也是一个项目的关键标识,推荐使用这个组织或团队的完整域名-->
5 <artifactId>ssim</artifactId> <!--工程的基本名称-->
6 <packaging>war</packaging> <!--打包的类型,可以为war、jar、ear等等-->
7 <version>1.0-SNAPSHOT</version> <!--项目版本号-->
8 <name>SSIM Maven Webapp</name> <!--工程显示的名称-->
9 <description> Web application</description> <!--对工程的基本描述-->
10
11 <build><!--主要用于编译设置-->
12 <finalName>${artifactId}</finalName>
13 <plugins>
14 <plugin>
15 <groupId>org.apache.maven.plugins</groupId>
16 <artifactId>maven-compiler-plugin</artifactId>
17 <configuration>
18 <source>1.6</source>
19 <target>1.6</target>
20 <encoding>UTF8</encoding>
21 </configuration>
22 </plugin>
23 <plugin>
24 <groupId>org.apache.maven.plugins</groupId>
25 <artifactId>maven-surefire-plugin</artifactId>
26 <version>2.4.2</version>
27 <configuration>
28 <skipTests>true</skipTests>
29 </configuration>
30 </plugin>
31 <plugin>
32 <artifactId>maven-war-plugin</artifactId>
33 <configuration>
34 <webappDirectory>${basedir}/src/main/webapp</webappDirectory>
35 <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
36 </configuration>
37 </plugin>
38 </plugins>
39 </build>
40 <!--定义依赖(项目中需要依赖的包-->
41 <dependencies>
42 <dependency>
43 <groupId>junit</groupId>
44 <artifactId>junit</artifactId>
45 <version>4.5</version>
46 <scope>test</scope>
47 </dependency>
48 </dependencies>
49 </project>
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4 <groupId>net.selitech.ssim</groupId> <!--工程的组织或团队的唯一标识,并且这个也是一个项目的关键标识,推荐使用这个组织或团队的完整域名-->
5 <artifactId>ssim</artifactId> <!--工程的基本名称-->
6 <packaging>war</packaging> <!--打包的类型,可以为war、jar、ear等等-->
7 <version>1.0-SNAPSHOT</version> <!--项目版本号-->
8 <name>SSIM Maven Webapp</name> <!--工程显示的名称-->
9 <description> Web application</description> <!--对工程的基本描述-->
10
11 <build><!--主要用于编译设置-->
12 <finalName>${artifactId}</finalName>
13 <plugins>
14 <plugin>
15 <groupId>org.apache.maven.plugins</groupId>
16 <artifactId>maven-compiler-plugin</artifactId>
17 <configuration>
18 <source>1.6</source>
19 <target>1.6</target>
20 <encoding>UTF8</encoding>
21 </configuration>
22 </plugin>
23 <plugin>
24 <groupId>org.apache.maven.plugins</groupId>
25 <artifactId>maven-surefire-plugin</artifactId>
26 <version>2.4.2</version>
27 <configuration>
28 <skipTests>true</skipTests>
29 </configuration>
30 </plugin>
31 <plugin>
32 <artifactId>maven-war-plugin</artifactId>
33 <configuration>
34 <webappDirectory>${basedir}/src/main/webapp</webappDirectory>
35 <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
36 </configuration>
37 </plugin>
38 </plugins>
39 </build>
40 <!--定义依赖(项目中需要依赖的包-->
41 <dependencies>
42 <dependency>
43 <groupId>junit</groupId>
44 <artifactId>junit</artifactId>
45 <version>4.5</version>
46 <scope>test</scope>
47 </dependency>
48 </dependencies>
49 </project>
2.4 在命令行下回到项目ssim目录下,运行
1mvn eclipse:eclipse
2.5 在myeclipse中导入生成的ssim项目,修改.mymetadata文件为
1<?xml version="1.0" encoding="UTF-8"?>
2<project-module
3 type="WEB"
4 name="ssim"
5 id="myeclipse.1234059775961"
6 context-root="/ssim"
7 j2ee-spec="1.4"
8 archive="ssim.war">
9 <attributes>
10 <attribute name="webrootdir" value="src/main/webapp" />
11 </attributes>
12</project-module>
2<project-module
3 type="WEB"
4 name="ssim"
5 id="myeclipse.1234059775961"
6 context-root="/ssim"
7 j2ee-spec="1.4"
8 archive="ssim.war">
9 <attributes>
10 <attribute name="webrootdir" value="src/main/webapp" />
11 </attributes>
12</project-module>
2.6修改.project文件为
1 <?xml version="1.0" encoding="UTF-8"?>
2 <projectDescription>
3 <name>ssim</name>
4 <comment>Web application</comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.jdt.core.javabuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 <buildCommand>
29 <name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>
30 <arguments>
31 </arguments>
32 </buildCommand>
33 <buildCommand>
34 <name>org.eclipse.wst.validation.validationbuilder</name>
35 <arguments>
36 </arguments>
37 </buildCommand>
38 </buildSpec>
39 <natures>
40 <nature>org.maven.ide.eclipse.maven2Nature</nature>
41 <nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
42 <nature>org.eclipse.jdt.core.javanature</nature>
43 <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
44 </natures>
45 </projectDescription>
46
2 <projectDescription>
3 <name>ssim</name>
4 <comment>Web application</comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.jdt.core.javabuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 <buildCommand>
29 <name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>
30 <arguments>
31 </arguments>
32 </buildCommand>
33 <buildCommand>
34 <name>org.eclipse.wst.validation.validationbuilder</name>
35 <arguments>
36 </arguments>
37 </buildCommand>
38 </buildSpec>
39 <natures>
40 <nature>org.maven.ide.eclipse.maven2Nature</nature>
41 <nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
42 <nature>org.eclipse.jdt.core.javanature</nature>
43 <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
44 </natures>
45 </projectDescription>
46
好了,用maven2构建的一个标准开发目录就建好了,将项目导入myeclipse,开发、调试、发布一举多得。
- maven构建项目(maven命令)
- Maven命令构建项目骨架
- 【Maven】maven 项目构建
- maven命令构建自己的java项目
- Maven项目构建命令compile、test、package
- [maven]构建maven web项目
- Maven-----构建Maven源码项目
- maven(2)------maven构建项目
- 【Maven】构建生成Maven项目
- Maven常用构建命令
- Maven - 构建与命令
- maven构建命令收集
- 使用Maven构建项目
- 使用Maven构建项目
- maven构建项目步骤
- 使用Maven构建项目
- Maven构建Web项目
- maven构建项目
- BASH 的基本语法
- Android 使用CountDownTimer实现倒计时动画
- 软件安装:RPM, SRPM, YUM
- 10305 - Ordering Tasks//拓扑排序
- 回车符和换行符区别
- maven构建项目(maven命令)
- Suse下启动mysql、apache服务命令
- Spring Mvc中@ResponseBody中文乱码解决
- Ruby属性与方法
- Hibernate的基本映射数据类型----(1)
- 相似图片搜索的原理
- log4j
- 获取spring容器中bean的方法
- Spring源码阅读之IoC容器初始化2 -- BeanDefinition载入与解析