zoukankan      html  css  js  c++  java
  • 解决eclipse部署maven项目无法导入lib的问题

    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>
  • 相关阅读:
    C#磁吸屏幕窗体类库
    准备
    我写的诗
    How to turn off a laptop keyboard
    How to tell which commit a tag points to in Git?
    Why should I care about lightweight vs. annotated tags?
    How to get rid of “would clobber existing tag”
    Facebook, Google and Twitter threaten to leave Hong Kong over privacy law changes
    The need for legislative reform on secrecy orders
    Can a foreign key be NULL and/or duplicate?
  • 原文地址:https://www.cnblogs.com/xy-ouyang/p/11059080.html
Copyright © 2011-2022 走看看