如何在 gwt 中使用 maven 在 eclipse 中创建 .war 文件



我想为我的GWTApp制造一场战争。根据许多教程,我会创建一个包,如下所示 -

 <package>war</package>

pom.xml.但是当我在tomcat上部署战争时,它向我显示 404 错误。战争不包含任何主机页面或依赖项。

以下是我的pom.xml文件-

  <modelVersion>4.0.0</modelVersion>
    <groupId>testing</groupId>
    <artifactId>testing</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
 <dependencyManagement>
   <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
    <artifactId>gwt</artifactId>
    <version>2.7.0</version>
    <type>pom</type>
    <scope>import</scope>
   </dependency>
   </dependencies>
 </dependencyManagement>
  <dependencies>
   <dependency>
     <groupId>com.google.gwt</groupId>
     <artifactId>gwt-user</artifactId>
     <scope>provided</scope>
    </dependency>
   <dependency>
     <groupId>com.google.gwt</groupId>
     <artifactId>gwt-dev</artifactId>
      <scope>provided</scope>
     </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-codeserver</artifactId>
     <scope>provided</scope>
   </dependency>
<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-servlet</artifactId>
  <scope>runtime</scope>
</dependency>
</dependencies>
   <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
       <excludes>
         <exclude>**/*.java</exclude>
       </excludes>
     </resource>
   </resources>
    <plugins>
      <plugin>
<!--         <artifactId>maven-compiler-plugin</artifactId> -->
       <artifactId>maven-war-plugin</artifactId>
<!--         <version>3.1</version> -->
        <configuration>
        <webXml>mavenWorkspacetestingwarWEB-INFweb.xml</webXml>
        <source/>
        <target/>
      </configuration>
    </plugin>
  </plugins>
</build>  

战争结构就像

war
   META-INF
    -maven
    -manifest
   WEB-INF
    -classes
    -lib
   -web.xml

和 lib 文件夹仅包含 gwt-servlet.jar .

看起来你的项目中没有 gwt-maven-plugin。GWT 需要一个编译步骤,因此请尝试添加该步骤。

最新更新