windows下的maven安装以及创建工程

windows下安装,需要配置系统的环境变量

检查maven 安装是否成功:用mvn -v

mvn archetype:generate   第一次运行特别慢,请耐心等待

创建java 普通工程           maven-archetype-quickstart
创建javaweb 工程           maven-archetype-webapp
编译源代码                      mvn compile
清空:                             mvn clean  (删除target目录)
生产站点目录                  mvn site
安装当前工程的输出文件到本地仓库  :mvn install    (C:\Users\lx\.m2\repository)
打包  mvn package
先清除再打包  mvn clean package
打成jar包  mvn jar:jar


在eclipse 创建工程 ,推荐使用eclipse-neon 版本

如果采用其他版本的ecipse 可能会出现如下错误

Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:maven-clean-plugin:maven-plugin:2.4.1:runtime Cause: error in opening zip file pom.xml /Test11 line 1  Maven Project Build Lifecycle Mapping Problem

关于这个错误,推荐使用eclipse-neon 版本,可避免出现错误

比如我的错误是:

Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:maven-clean-plugin:maven-plugin:2.4.1:runtime Cause: error in opening zip file pom.xml /Test11 line 1  Maven Project Build Lifecycle Mapping Problem

扫描二维码关注公众号,回复: 1036732 查看本文章

使用以下方法可解决这种错误:

右击项目,点击Maven  --> Add Plugin  -->填入相应的错误信息提示的有关项目的问题:

<plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-clean-plugin</artifactId>  
                <version>maven-plugin:2.4.1</version> 
</plugin>
配置成功后,点击OK,再次右击项目Maven  --->Update Project

特别提醒:Update Project 后,容易出现其他问题比如 out of date 之类的错误

强烈推荐  eclipse- neon版本开发有关maven 项目  ,同时eclipse-neon 需要jdk1.8版本


猜你喜欢

转载自blog.csdn.net/lu__ya/article/details/78945247
今日推荐