没有生成WAR文件

时间:2014-04-09 21:15:21

标签: maven war pom.xml

当我运行mvn clean install时,会生成JAR文件,而不是WAR文件。我错过了什么吗?我正在运行Maven 3.2.1,并且我正在尝试将一个非常简单的Web应用程序部署到Tomcat。

<?xml version="1.0" encoding="UTF-8"?>

<project>
  <modelVersion>4.0.0</modelVersion>
  <name>Cafe Iteration 1 - Sakai Hello</name>
  <groupId>sakaiproject</groupId>
  <artifactId>sakai-cafe-iteration1-tool</artifactId>
  <version>0.1</version>
  <organization>
      <name>Sakai Foundation</name>
      <url>http://sakaiproject.org/</url>
  </organization>
  <inceptionYear>2004</inceptionYear>

  <properties>
      <deploy.type>war</deploy.type>
  </properties>

  <dependencies>
      <!-- Java Servlets -->
      <dependency>
          <groupId>servletapi</groupId>
          <artifactId>servletapi</artifactId>
          <version>2.4</version>
      </dependency>

  </dependencies>

  <build>
      <sourceDirectory>src/java</sourceDirectory>
  </build>

</project>

这是一些输出:

// ... etc ...
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sakai-cafe-iteration1-tool ---
[INFO] Building jar: C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\tasklist\target\sakai-cafe-iteration1-tool-0.1.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ sakai-cafe-iteration1-tool ---
[INFO] Installing C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\tasklist\target\sakai-cafe-iteration1-tool-0.1.jar to C:\Users\BJ Peter DeLaCruz\.m2\repository\sakaiproject\sakai-cafe-iteration1-tool\0.1\sakai-cafe-iteration1-tool-0.1.jar
[INFO] Installing C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\tasklist\pom.xml to C:\Users\BJ Peter DeLaCruz\.m2\repository\sakaiproject\sakai-cafe-iteration1-tool\0.1\sakai-cafe-iteration1-tool-0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
// ... etc ...

1 个答案:

答案 0 :(得分:2)

<packaging>war</packaging>添加到您的POM。通常我会把它放在<version>下。