在Java EE7项目中找不到web.xml [英] web.xml not found in Java EE7 project
问题描述
我正在使用JSF 2.2和Servlet 3.1(Java EE7)在eclipse中进行项目.我遇到的第一个问题是以下行中的pom.xml错误:
I'm doing a project in eclipse with JSF 2.2 and Servlet 3.1 (Java EE7). The first problem I had was a error in the pom.xml in line:
<packaging>war</packaging>
错误:缺少web.xml并将其设置为true.
我在互联网上进行了研究,并在pom.xml中添加了以下几行
I researched on the internet and added the following lines in my pom.xml
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
之后,错误消失了,但是在运行项目时出现错误:
After that the error was gone, but when running the project get the error:
java.lang.NoClassDefFoundError:javax/servlet/jsp/jstl/core/Config
我再次搜索了Internet,并将以下几行内容放入pom.xml
I searched the Internet again and put the following lines in pom.xml
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
仅在例如访问时,问题才解决:
The problem solved, only when access for example:
http://localhost:8080/MeuSistema/Login.jsf
http://localhost:8080/MeuSistema/Login.jsf
(我将jsf映射为inves xhtml)
(I put mapped as jsf to inves xhtml)
他通过jsp声明以下内容来更改jsf:
He changes the jsf by jsp stating the following:
HTTP状态404-/MeuSistema/Login.jsp
出于好奇,将.jsf更改为.xhtml以查看是否至少打开了 该文件,它将返回以下内容:
Out of curiosity changing the .jsf to .xhtml to see if opened at least the file, it returns the following:
HTTP状态404-在ExternalContext中找不到/Login.xhtml作为资源
我还发现了这种替代方法,可以强制读取web.xml
I also found this alternative to force to read the 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:
Follow my pom.xml and web.xml:
好吧,看来这不是在读取web.xml.有趣的是 没有任何控制台错误.
Well, it seems that is not reading the web.xml. Funny that in not of any console error.
有什么问题吗? 感谢您的关注.
What can be wrong? Thanks for attention.
推荐答案
已解决-仅删除了我项目中的文件夹 .metada .项目 .设置 .classpath
Solved - just deleted folders within my project .metada .project .settings .classpath
谢谢
这篇关于在Java EE7项目中找不到web.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!