将IntelliJ IDEA创建的Web项目转换为MyEclipse版本的Web项目

Java核心 2014-12-27

将IntelliJ IDEA创建的Web项目转换为MyEclipse版本的Web项目,主要创建如下文件,并修改其中的内容:

一、.project文件(注意前面的·)

<span style="color:#888888;"><?xml version=”1.0″ encoding=”UTF-8″?>

<projectDescription>

</span><span style="color:#ff0000;"><name>Test</name></span><span style="color:#888888;">

<comment></comment>

<projects>

</projects>

<buildSpec>

<buildCommand>

<name>org.eclipse.wst.common.project.facet.core.builder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.eclipse.jdt.core.javabuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.eclipse.wst.validation.validationbuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>

<arguments>

</arguments>

</buildCommand>

</buildSpec>

<natures>

<nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>

<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>

<nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>

<nature>org.eclipse.jdt.core.javanature</nature>

<nature>org.eclipse.wst.jsdt.core.jsNature</nature>

<nature>org.eclipse.wst.common.project.facet.core.nature</nature>

<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>

</natures>

</projectDescription></span>

主要修改的是name,将name修改为你具体工程的名称。

二、.classpath

<span style="color:#888888;"><?xml version=”1.0″ encoding=”UTF-8″?>

<classpath>

</span><span style="color:#ff0000;"><classpathentry kind=”src” path=”src”/></span><span style="color:#888888;">

<classpathentry kind=”con” path=”org.eclipse.jdt.launching.JRE_CONTAINER”/>

<classpathentry kind=”con” path=”melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_6_CONTAINER”/>

<classpathentry kind=”con” path=”org.eclipse.jst.j2ee.internal.web.container”/>

<classpathentry kind=”con” path=”org.eclipse.jst.j2ee.internal.module.container”/>

</span><span style="color:#ff0000;"><classpathentry kind=”output” path=”web/WEB-INF/classes”/></span><span style="color:#888888;">

</classpath></span>

主要修改的是src属性和output属性,修改为你工程具体的路径,例如,本人的web元素是放在web下的,MyEclipse创建的工程默认是放在WebRoot目录下的

三、.mymetadata

<span style="color:#888888;"><?xml version=”1.0″ encoding=”UTF-8″?>

<project-module

</span><span style="color:#ff0000;">  type=”WEB”</span><span style="color:#888888;">

</span><span style="color:#ff0000;">  name=”Test”</span><span style="color:#888888;">

  id=”myeclipse.1407308101935″

</span><span style="color:#ff0000;">  context-root=”/Test”</span><span style="color:#888888;">

  j2ee-spec=”6.0″

</span><span style="color:#ff0000;">  archive=”Test.war”></span><span style="color:#888888;">

  <attributes>

  </span><span style="color:#ff0000;">  <attribute name=”webrootdir” value=”web” /></span><span style="color:#888888;">

  </attributes>

</project-module></span>

修改具体对应的项目名称为你工程对应的

四、创建目录.settings

在该目录下主要创建如下6个文件:

(1) org.eclipse.core.resources.prefs

#Wed Aug 06 15:01:06 CST 2014

eclipse.preferences.version=1

encoding/<project>=UTF-8

(2) org.eclipse.jdt.core.prefs

#Wed Aug 06 14:55:08 CST 2014

eclipse.preferences.version=1

org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled

org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6

org.eclipse.jdt.core.compiler.compliance=1.6

org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

org.eclipse.jdt.core.compiler.source=1.6

(3) org.eclipse.wst.common.component

<span style="color:#888888;"><?xml version=”1.0″ encoding=”UTF-8″?>

<project-modules id=”moduleCoreId” project-version=”1.5.0″>

    </span><span style="color:#ff0000;"><wb-module deploy-name=”Test”></span><span style="color:#888888;">

        </span><span style="color:#ff0000;"><wb-resource deploy-path=”/” source-path=”/web”/></span><span style="color:#888888;">

        </span><span style="color:#ff0000;"><wb-resource deploy-path=”/WEB-INF/classes” source-path=”/src”/></span><span style="color:#888888;">

      </span><span style="color:#ff0000;"> <property name=”context-root” value=”/Test”/></span><span style="color:#888888;">

        </span><span style="color:#ff0000;"><property name=”java-output-path” value=”/Test/web/WEB-INF/classes”/></span><span style="color:#888888;">

    </wb-module>

</project-modules></span>

修改每个路径为你工程目录对应的路径

(4) org.eclipse.wst.common.project.facet.core.xml

<?xml version=”1.0″ encoding=”UTF-8″?>

<faceted-project>

  <fixed facet=”wst.jsdt.web”/>

  <installed facet=”java” version=”1.6″/>

  <installed facet=”jst.web” version=”3.0″/>

  <installed facet=”wst.jsdt.web” version=”1.0″/>

</faceted-project>

(5) org.eclipse.wst.jsdt.ui.superType.container

空目录,创建这个文件即可;

(6) org.eclipse.wst.jsdt.ui.superType.name

空目录,创建这个文件即可。

执行完上述步骤之后,就可以使用MyEclipse的import选项导入进去了。

IntelliJ IDEA 的详细介绍:请点这里
IntelliJ IDEA 的下载地址:请点这里

相关推荐