maven快速入门新建项目, 卡慢问题解决

来源:互联网 发布:c语言取绝对值 编辑:程序博客网 时间:2024/06/04 22:49

一般情况下, 公司所有的开发环境都是配好的,  如果自己动手呢, 会遇到什么问题?  闲来无事, 自己动动手, 记录下maven新建项目会遇到的问题.

下面是新建一个项目的步骤, 使用maven的过程中, 如果网速不快的话, 经常会遇到下载一些远程资源时, 非常慢, 很影响开发效率.

1. 打开dos界面

2.新建项目, 输入命令 mvn archetype:generate -DgroupId=com.ha -DartifactId=firstMvnApp -DarchetypeArtifactId=maven-archetype-quickstart 新建一个名叫firstMvnApp的项目(注意-D  大写)

可以看到, 在红框这行卡住了. 


解决办法 :   

3. 新建项目时, 输入命令 mvn archetype:generate -DgroupId=com.ha -DartifactId=firstMvnApp -DarchetypeArtifactId=maven-archetype-quickstart-DinteractiveMode=false


可以看到, 在红框这又!!卡住了!

解决办法: 

4. 新建项目前, 从http://repo1.maven.org/maven2/archetype-catalog.xml把archetype-catalog.xml文件下载,乖乖,这个文件有5+M,  我家10M网速, 下了1分钟!!

文件放到目录F:\Maven\local_repositories\org\apache\maven\archetype\archetype-catalog\3.0.0下面(这里F:\Maven\local_repositories是我自定义配置的本地仓库目录,win7系统默认本地仓库目录是C:\Users\huangjc\.m2\repository).

5. 新建项目时, 输入命令mvn archetype:generate -DgroupId=com.ha -DartifactId=firstMvnApp -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=local


可以看到, 1.376s就新建完了.  项目文件目录在C:\Users\huangjc\firstMvnApp

5.查看项目的目录结构



yeah, nice  over! 


0 0