首页 > 代码库 > 将Maven的Java Project修改为Web Project
将Maven的Java Project修改为Web Project
将Maven的Java Project修改为Web Project关键是需要了解Eclipse和MyEclipse的工程中如下文件.classpath和.project和.mymetadata含义和作用。
.project文件,本文主题将Maven的Java Project改为Web Project,关键是如下配置:
<?xml version=”1.0”encoding=”UTF-8”?><?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<!-- 工程名称-->
<name>trust_product_admin</name>
<comment></comment>
<projects>
</projects>
<!-- 编译器指定<buildSpec>,此处省略相关buildCommand-->
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<!-- 运行时需要的额外Eclipse插件-->
<natures>
<!-- 本文主题将Maven的Java Project改为Web Project的关键组件即webnature-->
<nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
<nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
.classpath文件详细描述:
<?xml version=”1.0”encoding=”UTF-8”?>
<classpath>
<!-- 源码目录 -->
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<!-- JDK运行时容器 -->
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_20"/>
<!-- 引用Maven相关jar包 -->
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value=http://www.mamicode.com/"true"/>
<attribute name="org.eclipse.jst.component.dependency" value=http://www.mamicode.com/"/WEB-INF/lib"/>
</attributes>
</classpathentry>
<!-- 编译后输出class目录 -->
<classpathentry kind="output" path="target/classes"/>
</classpath>
对于myeclipse工程多了一个.mymetadata文件:
<?xml version=”1.0”encoding=”UTF-8”?>
type : 工程类型
name : 工程名称
id : 工程在工作空间内的唯一标识
context-root : 系统根路径
j2ee-spec: J2EE标准
archive : 打包后war文件
-->
<project-module
type="WEB"
name="trust_product_admin"
id="myeclipse.1411629788403"
context-root="/trust_product_admin"
j2ee-spec="5.0"
archive="trust_product_admin.war">
<attributes>
<!-- value : Web根目录名称-->
<attribute name="webrootdir" value=http://www.mamicode.com/"src/main/webapp" />
</attributes>
</project-module>
将Maven的Java Project修改为Web Project