开发环境eclipse、myEclipse本地tomcat调试发布maven项目遇到的糟心事

  之前一直用myEclipse开发Web Project项目,通过myEclipse本地部署tomcat还算顺利,但是有个问题,myEclipse中Java Compiler只支持到1.7,但是spring boot要求至少是jdk1.8,所以放弃了myEclipse转为eclipse,至于idea后面再说吧。这里先说一下开发环境eclipse、myEclipse本地tomcat调试发布maven项目遇到的糟心事。

  (1)myEclipse部署maven项目到tomcat上识别不了项目,无法部署

  解决方法:右键项目Properties,找到myEclipse->Project Facets勾选上Dynamic Web Module,其他是否勾还不确定,先按照默认的吧,如图:

  (2) eclipse部署maven项目到tomcat上识别不了项目,无法部署

  解决方法:右键项目Properties,找到Project Facets勾选上Dynamic Web Module,其他是否勾还不确定,先按照默认的吧,如图

  (3) eclipse已经配好tomcat,发布不到tomcat的webapps目录下

  可能原因1:没有设置发布的目录,需要如下图设置:

  可能原因2:没有点击publish按钮,如下图(新修改的代码没有编译到tomcat下,也需要点此按钮)

  (4) eclipse中由于一通乱整,可能导致项目没有了Maven Dependencies包

  我处理的方法是:把一个可以正常显示的项目的.project文件拷贝一份,替换到该项目中。附一个正常的:

<?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" path="src/main/webapp"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java">
        <attributes>
            <attribute name="test" value="true"/>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
        <attributes>
            <attribute name="test" 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.8">
        <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"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
View Code

  (5)eclipse发布或者打war包到tomcat中缺少lib包或者其他文件

  解决方法:右键项目Properties,找到Deployment Assembly设置java、resources、webapp、Maven Dependencies 如下:

  

猜你喜欢

转载自www.cnblogs.com/javasl/p/12356407.html