4

我正在使用 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。有趣的是,没有任何控制台错误。

有什么问题?感谢关注。

4

2 回答 2

4

已解决 - 刚刚删除了我的项目 .metada .project .settings .classpath 中的文件夹

谢谢

于 2015-07-17T17:27:49.343 回答
0

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

<properties>        
<failOnMissingWebXml>false</failOnMissingWebXml>    
</properties>
于 2017-08-12T11:17:42.707 回答