maven构建后无法运行Web项目

时间:2015-11-13 10:59:51

标签: java eclipse maven tomcat

我是Maven的新手。我正在尝试使用maven和eclipse kepler构建一个Web项目。但是在我使用干净安装运行maven build之后,.xhtml文件不在web-inf文件夹中,这最终会给资源找不到错误

My folder structure

的web.xml

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>CassandraPrimefacesKunderaIntegration</display-name>
  <welcome-file-list>
    <welcome-file>home.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

没有依赖项的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>CassandraPrimefacesKunderaIntegration</groupId>
  <artifactId>CassandraPrimefacesKunderaIntegration</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>CassandraPrimefacesKunderaIntegration</name>

  <url>http://maven.apache.org</url>

<build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>        
      </plugin>
    </plugins>
  </build>

当我使用全新安装调用maven build时,目标文件夹如下所示

target folder structure

部署程序集 - &gt;

src/main/java -->WEB-INF/classes
src/main/resources -->WEB-INF/classes
src/main/webapp -->WEB-INF/classes

现在,当我从Tomcat运行项目时(右键单击 - &gt;运行为 - &gt;在服务器上运行),它显示&#34;资源不可用&#34;错误

2 个答案:

答案 0 :(得分:1)

首先尝试maven - 更新项目,然后再次清理并构建应用程序。

答案 1 :(得分:0)

我在项目结构中没有看到部署描述符。如果已标记动态Web模块,请检入Project Facets。