从pom.xml上的com.google.gwt依赖项中排除javax.servlet包

时间:2014-06-10 09:44:01

标签: java maven gwt dependencies vaadin

我使用Vaadin 7,vaadin有一个默认包javax.servlet,我的依赖项中需要com.google.gwt,其中包含另一个javax.servlet。当我运行我的应用程序时,我收到了这个错误:

SEVERE: Allocate exception for servlet Vaadin Application Servlet
java.lang.ClassCastException: com.vaadin.server.VaadinServlet cannot be cast to javax.servlet.Servlet

现在我想从这个依赖项中排除javax.servlet,这是我到目前为止所尝试的:

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.6.1</version>
  <exclusions>
    <exclusion>  <!-- declare the exclusion here -->
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>

和此:

<build>
<plugins>
<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>2.3</version>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <filters>
              <filter>
                <minimizeJar>true</minimizeJar>
                <artifact>com.google.gwt:gwt-user</artifact>
                <includes>
                  <include>com/google/**</include>
                </includes>
                <excludes>
                  <exclude>javax/servlet/**</exclude>
                  <exclude>javax/servlet/http/**</exclude>
                  <exclude>javax/servlet/resources/**</exclude>
                </excludes>
              </filter>
            </filters>
          </configuration>
        </execution>
      </executions>
    </plugin>
 <plugin>

但两者都不起作用!救命啊!

2 个答案:

答案 0 :(得分:2)

我认为你实际上想要gwt-servlet依赖而不是gwt-user

那说,我不认识瓦丁;也许有一个包含GWT类的com.vaadin依赖项?

答案 1 :(得分:1)

根据您的第二次尝试,以下面给出的方式排除所需的包裹:

示例:

                <configuration>
                        <packagingExcludes>
                           WEB-INF/lib/servlet-api*.jar,
                           WEB-INF/lib/jsp-api*.jar,
                           WEB-INF/lib/jstl-api*.jar,
                    </packagingExcludes>
                </configuration>