有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么GWT2.5.1在Maven repo中缺失?

我刚刚安装了m2e(Maven Eclipse插件),并创建了一个具有快速启动原型的新Maven项目。然后,我转到official Maven repo以下拉GWT2.5.1的依赖项,并查看它希望您将以下<dependency>元素添加到项目的pom.xml文件中:

<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt</artifactId>
    <version>2.5.1</version>
</dependency>

总之,我的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>com.me.myorg</groupId>
    <artifactId>maven-resolver</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>maven-resolver</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt</artifactId>
            <version>2.5.1</version>
        </dependency>
    </dependencies>
</project>

我得到以下错误:

Missing artifact com.google.gwt:gwt:jar:2.5.1

此外,在Eclipse的包资源管理器中,在我的项目的Maven Dependencies库下,没有任何问题得到解决

这是怎么回事?提前谢谢

更新:~/.m2/repository/com/google/gwt/gwt/2.5.1内容如下:

gwt-2.5.1.jar.lastUpdated  gwt-2.5.1.pom.sha1
gwt-2.5.1.pom              _maven.repositories

共 (1) 个答案

  1. # 1 楼答案

    这个gwt dependencie是gwt项目的父pom。这意味着回购协议将只包含散列和pom,而不包含jar

    您需要使用两个库:gwt-servletgwt-user

    我为GWT开发找到了这种配置(也许您不需要像前面所描述的那样放置<scope>):

     <dependencies>
        <dependency>
          <groupId>com.google.gwt</groupId>
          <artifactId>gwt-servlet</artifactId>
          <version>2.5.1</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>com.google.gwt</groupId>
          <artifactId>gwt-user</artifactId>
          <version>2.5.1</version>
          <scope>provided</scope>
        </dependency>
      <dependencies>
    

    删除依赖项并用上面显示的这两个更新pom

    您还可以使用gwt-maven-plugin来管理gwt项目,并通过maven进行部署。我在那里找到了这些信息

    我希望这能奏效