使用myeclipse 2014创建java project几次都没有成功,还是觉得用maven创建java project然后导入到myeclipse ide中,比较方便.
首先在workspace目录下面创建maven工程,mvn archetype:create -DgroupId=com.test -DartifactId=test.控制台输出如下:
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: packageName, Value: com.test
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: artifactId, Value: test
[INFO] Parameter: basedir, Value: /opt/app-w/MyEclipse Professional 2014/workspace/singleton
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /opt/app-w/MyEclipse Professional 2014/workspace/singleton/test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:50 min
[INFO] Finished at: 2015-02-07T16:07:10+08:00
[INFO] Final Memory: 13M/246M
[INFO] ------------------------------------------------------------------------
之后生成eclipse ide导入需要的文件.classpath和 和.project,使用命令: mvn eclipse:eclipse,这样就可以导入到myeclipse ide中了.先导入一个exiting maven projects,选择next,然后选择finish.就完成一个java工程的创建和导入到myeclipse中.
如果想要转化为dynamic web project的话,还需要转化为web工程,在工程的属性中,修改project facets中,选中dynamic web project属性.
点击上图中蓝色字体部分,配置webapp目录
最后可以看到test工程的目录结构为:
这样就完成了maven创建java project,然后导入到myeclipse ide中,再而转化为dynamic web project.