Java項目与Java web項目的.project文件



Java項目的.project文件



 



[html] view plain copy print ?




<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>rop-sample</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.maven.ide.eclipse.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.maven.ide.eclipse.maven2Nature</nature>
	</natures>
</projectDescription>



 



 



java web 項目的.project文件



 



[html] view plain copy print ?

1. <?xml version="1.0" encoding="UTF-8"?>
2. <projectDescription>
3. <name>rop-helloworld</name>
4. <comment></comment>
5. <projects>
6. </projects>
7. <buildSpec>
8. <buildCommand>
9. <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10. <arguments>
11. </arguments>
12. </buildCommand>
13. <buildCommand>
14. <name>org.eclipse.jdt.core.javabuilder</name>
15. <arguments>
16. </arguments>
17. </buildCommand>
18. <buildCommand>
19. <name>org.eclipse.wst.common.project.facet.core.builder</name>
20. <arguments>
21. </arguments>
22. </buildCommand>
23. <buildCommand>
24. <name>org.eclipse.wst.validation.validationbuilder</name>
25. <arguments>
26. </arguments>
27. </buildCommand>
28. <buildCommand>
29. <name>org.maven.ide.eclipse.maven2Builder</name>
30. <arguments>
31. </arguments>
32. </buildCommand>
33. <buildCommand>
34. <name>org.eclipse.m2e.core.maven2Builder</name>
35. <arguments>
36. </arguments>
37. </buildCommand>
38. </buildSpec>
39. <natures>
40. <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
41. <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
42. <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
43. <nature>org.eclipse.jdt.core.javanature</nature>
44. <nature>org.maven.ide.eclipse.maven2Nature</nature>
45. <nature>org.eclipse.m2e.core.maven2Nature</nature>
46. <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
47. </natures>
48. </projectDescription>



 

 

 

Web项目中 .classpath、.mymetadata、.project文件的作用
创建Web Project时,会自动生成这个三个文件。
一、.mymetadata文件
1、部署项目用的,把项目部署到tomcat服务器上时,如果没有这个文件,用myeclipse/Eclipse部署是不能部署到关联的tomcat服务器。
.mymetadata文件:



<?xml version=”1.0” encoding=”UTF-8”?>
<!--
type : 工程类型
name : 工程名称
id : 工程在工作空间内的唯一标识
context-root : 网站根路径
j2ee-spec: J2EE标准
archive : 打包后war文件
-->
<project-module
type=”WEB”
name=”PheebsKM”
id=”myeclipse.1152954865843”
context-root=”/PheebsKM”
j2ee-spec=”1.4”
archive=”PheebsKM.war”>

<attributes>
  <!-- value : Web根目录名称 -->
    <attribute name=”webrootdir” value=”WebRoot” />
</attributes>
</project-module>



2、在MyEclipse/Eclipse更改项目发布到Tomcat的文件夹
   (1)、在自己的workspace中找到当前使用的项目,找到文件.mymetadata,打开后就会看见标签context- root=”/example”(example是自己应用的名称),可以将其改为别的名称。
   (2)、选择:工程右键 --》Properties --》Myeclipse --》 Web
   [Web-root folder]:/WebRoot
   [Web Context-root]:/ROOT,修改context-root对应的值即可。(默认值:当前项目名称)
二、.project文件



<?xml version=”1.0” encoding=”UTF-8”?>
<projectDescription>
<!-- 工程名称 <name>-->
<name>PheebsKM</name>
<comment></comment>
<projects></projects>
<!-- 编译器指定 <buildSpec>-->
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments></arguments>
</buildCommand>
</buildSpec>
<!-- 核心特性 <natures> -->
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>


对于.project文件不需要手动修改。

三、.classpath文件


<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <!-- 源码目录 -->
	<classpathentry excluding="main/|webservices/|patterns/|web/|jdk/|resources/|jquery/|util/|jdon/|hotel/" kind="src" path="src"/>
	<classpathentry kind="src" path="src/hotel"/>
	<classpathentry kind="src" path="src/jdon"/>
	<classpathentry kind="src" path="src/webservices"/>
	<classpathentry kind="src" path="src/patterns"/>
	<classpathentry kind="src" path="src/web"/>
	<classpathentry kind="src" path="src/jdk"/>
	<classpathentry kind="src" path="src/resources"/>
	<classpathentry kind="src" path="src/jquery"/>
	<classpathentry kind="src" path="src/util"/>
        <!-- JDK运行时容器 -->
	<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_17"/>
       <!-- 以下为类库,path为自定义的目录,需要导入的jar文件 -->
	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/lib_jar"/>
        <!-- 编译后输出class目录 -->
	<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>



说明
   1、有时候在一个Web工程里我们需要加入第三方jar包,这时你加入的最好相对路径,
而不是绝对路径。否则你的工程拿到别处就不能运行了。意思就是说你最好把相关的jar放到工程目录下。对于Web工程来说相对简单,web工程是有个lib目录的。直接复制到这里就行了。
  2、若在eclipse中导入其他项目,除了更改引入jar目录外,还可能需要修改.project或.mymetadata文件。