eclipse版本為2018-12(4.10.0)
1、默認tomcat的server配置

改成:

2、項目部署
按上面的配置,項目會部署到你配置的本地tomcat的webapps目錄下。



部署了項目jweb-jweb和jweb-jwebapi,發現其中一個項目確實lib目錄,即第三方jar包沒有進來,顯然這樣會導致啟動失敗,Class找不到。
3、比較兩個項目的.classpath文件的不同,發現jweb-apiweb中多了這個配置:

<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>
以及把<attribute name="maven.pomderived" value="true"/>改成 <attribute name="owner.project.facets" value="java"/>,否則項目部署有lib目錄,但仍然啟動失敗。
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry>
4、配置出現問題的原因
創建jweb-jweb項目時打包方式為jar,創建好后手動到pom文件中修改jar為war。而jweb-apiweb是直接eclpse創建maven工程時指定為war。
貼一下沒問題時.classpath的內容,以作為對照:eclipse版本為2018-12(4.10.0)
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="src" output="target/test-classes" path="src/test/java"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> <attribute name="test" value="true"/> </attributes> </classpathentry> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> <attribute name="test" 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="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <attributes> <attribute name="owner.project.facets" value="java"/> </attributes> </classpathentry> <classpathentry kind="output" path="target/classes"/> </classpath>
