Myeclise 中web项目部署到tomcat时Deploy Location 是 INVALID的解决方案
弄了一个maven的web项目,想要将web项目直接部署到tomcat的ROOT下,但部署的时候Deploy Location 是 INVALID。
检查项目根目录下的.settings文件夹中的org.eclipse.wst.common.component
<?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="myproject"> <wb-resource deploy-path="/" source-path="/WebRoot"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> <property name="java-output-path" value="/myproject/WebRoot/WEB-INF/classes"/> <property name="context-root" value="/"/> </wb-module> </project-modules>
注意属性context-root的value需要是/
因为本身是maven项目,还需要修改classpath
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry including="**/*.*" kind="src" output="WebRoot/WEB-INF/classes" path="src"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="maven.pomderived" value="true"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> <classpathentry kind="con" path="com.genuitec.runtime.library/com.genuitec.generic_7.0"> <attributes> <attribute name="owner.project.facets" value="jst.web"/> </attributes> </classpathentry> <classpathentry kind="output" path="WebRoot/WEB-INF/classes"/> </classpath>
原来的第一个classpathentry的值是:
<classpathentry including="**/*.java" kind="src" output="WebRoot/WEB-INF/classes" path="src">
需要修改为:
<classpathentry including="**/*.*" kind="src" output="WebRoot/WEB-INF/classes" path="src">
否则src根中的一些配置文件是不会被编译到WEB-INF/classes目录下的