【问题标题】:web.xml not found in Java EE7 project在 Java EE7 项目中找不到 web.xml
【发布时间】:2017-08-12 19:17:42
【问题描述】:

我正在使用 JSF 2.2 和 Servlet 3.1 (Java EE7) 在 eclipse 中做一个项目。我遇到的第一个问题是 pom.xml 中的错误:

<packaging>war</packaging>

错误:web.xml 丢失并设置为 true。

我在互联网上研究并在我的 pom.xml 中添加了以下几行

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>    
    </configuration>
</plugin>

之后错误消失了,但是在运行项目时出现错误:

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

我又上网搜索了一下,在pom.xml中放了以下几行

<dependency>    
    <groupId>jstl</groupId> 
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

问题解决了,只有当访问举例:

http://localhost:8080/MeuSistema/Login.jsf

(我把映射为jsf到inves xhtml)

他通过 jsp 更改了 jsf,声明如下:

HTTP 状态 404 - /MeuSistema/Login.jsp

出于好奇将 .jsf 更改为 .xhtml 以查看是否至少打开 该文件,它返回以下内容:

HTTP 状态 404 - 在 ExternalContext 中未找到 /Login.xhtml 作为资源

我还发现了强制读取 web.xml 的替代方法

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <webxml>src/main/webapp/WEB-INF/web.xml</webxml>
        <warSourceDirectory>src/main/webapp/</warSourceDirectory>
    </configuration>
</plugin>

但问题依旧。

关注我的 pom.xml 和 web.xml:

http://pastebin.com/43nqctAn

http://pastebin.com/GbqR9j9v

嗯,看来是没有读取web.xml。有趣的是在 没有任何控制台错误。

有什么问题吗? 感谢关注。

【问题讨论】:

    标签: maven java-ee-7 servlet-3.1


    【解决方案1】:

    已解决 - 刚刚删除了我项目中的文件夹 .元数据 。项目 .settings .classpath

    谢谢

    【讨论】:

      【解决方案2】:

      只需在项目的 pom.xml 中添加以下行。

      <properties>        
      <failOnMissingWebXml>false</failOnMissingWebXml>    
      </properties>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-19
        • 2016-04-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多