gwt-servlet.jar missing in the WEB-INF/lib on compiling GWT with maven

荒凉一梦 提交于 2020-01-01 19:35:34

问题


In my pom file, I have included the dependency of gwt-servlet but if i run mvn clean install and mvn eclipse:eclipse and open the project in eclipse, I get the following error

GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory

EDIT : Here is my dependency (we use a custom maven repository):

<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-user</artifactId>
    <version>2.4.0</version>
</dependency>
<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-servlet</artifactId>
    <version>2.4.0</version>
</dependency>
<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smart-gwt</artifactId>
    <version>2.5</version>
</dependency>

EDIT 2 (main pom):

<build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ftp</artifactId>
      </extension>
    </extensions>
....

回答1:


There are two things I noticed.

1) The smartgw dependency you specified cannot be resolved from the maven central repository

<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smart-gwt</artifactId>
    <version>2.5</version>
</dependency>

It only has the 2.4 version of smartgw (see here http://search.maven.org/#search%7Cga%7C1%7Csmartgwt) Instead I had to use this

<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smartgwt</artifactId>
    <version>2.4</version>
</dependency>

notice that the artifact ID is different too. (If you have a custom repository containing this then please update your question)

2) You dont need to do eclipse:eclipse instead you can issue the

File > Import > Existing Maven projects

this will auto generate the eclipse project from your pom.xml

UPDATE

I tested with the following :

Parent pom in gwttest2 folder

<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>com.test</groupId>
    <artifactId>gwttest2-main</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>gwttest2-module1</module>
    </modules>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ftp</artifactId>
            </extension>
        </extensions>
    </build>


    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt</artifactId>
            <version>2.4</version>
        </dependency>

    </dependencies>

</project>

child pom in gwttest2/gwttest2-module1 folder

<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>com.test</groupId>
    <artifactId>gwttest2-module1</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <parent>
        <artifactId>gwttest2-main</artifactId>
        <groupId>com.test</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ftp</artifactId>
            </extension>
        </extensions>
    </build>


    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt</artifactId>
            <version>2.4</version>
        </dependency>

    </dependencies>

</project>



回答2:


Tell Eclipse to use Maven dependencies by right-clicking on your Project folder and selecting

Configure > Convert to Maven Project.

It seems that even after running mvn eclipse:eclipse, you must do this manually to get Eclipse to actually let Maven take care of your dependencies.

If you don't see this option you may not have the M2Eclipse plugin installed in your Eclipse...



来源:https://stackoverflow.com/questions/8564091/gwt-servlet-jar-missing-in-the-web-inf-lib-on-compiling-gwt-with-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!