当前位置: 首页 > 知识库问答 >
问题:

gwt maven插件生成的maven项目无法通过导入现有maven项目导入eclipse

焦驰
2023-03-14

我首先通过执行生成了一个gwt maven项目-

mvn原型:生成-Darch etypeGroupId=org.codehaus.mojo-Darch etypeartifactId=gwt-maven-plugin-Darch etypeVersion=2.7.0

在那之后,pom。xml如下所示:

        <?xml version="1.0" encoding="UTF-8"?>
    <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/maven-v4_0_0.xsd">

      <modelVersion>4.0.0</modelVersion>
      <groupId>com.boye.games</groupId>
      <artifactId>games-gwt</artifactId>
      <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>GWT Maven Archetype</name>

      <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.7.0</gwtVersion>

        <!-- GWT needs at least java 1.6 -->
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>

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

      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt</artifactId>
            <version>${gwtVersion}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>

      <dependencies>
        <dependency>
          <groupId>com.google.gwt</groupId>
          <artifactId>gwt-servlet</artifactId>
          <scope>runtime</scope>
        </dependency>
        <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>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.11</version>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <build>
        <!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode -->
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>

        <plugins>

          <!-- GWT Maven Plugin -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.7.0</version>
            <executions>
              <execution>
                <goals>
                  <goal>compile</goal>
                  <goal>test</goal>
                  <goal>generateAsync</goal>
                </goals>
              </execution>
            </executions>
            <!-- Plugin configuration. There are many available options, see 
              gwt-maven-plugin documentation at codehaus.org -->
            <configuration>
              <runTarget>LineThree.html</runTarget>
              <modules>
                <module>com.boye.games.linethree.LineThree</module>
              </modules>
            </configuration>
          </plugin>
        </plugins>
      </build>

    </project>

然后我通过内置的eclipse函数将这个项目导入eclipse——导入现有的Maven项目。

但是,由于以下几个原因,该过程失败:

  1. GreetingServiceAsync无法解析为类型

插件组织。科德豪斯。mojo:gwtmaven插件:2.7。无法解析0或其某个依赖项:未能收集组织的依赖项。科德豪斯。mojo:gwtmaven插件:jar:2.7。0()(org.codehaus.mojo:gwt-maven插件:2.7.0:generateAsync:default:generateSources)

我的环境如下:

  1. java版本1.7。0_03

请多多指教,谢谢!

共有3个答案

阚乐湛
2023-03-14

这是我的工作:

我删除了本地maven gwt存储库,在windows 7中它在C:\用户\. m2\repository\com\google\gwt中,然后制作一个

mvn clean complile

所以maven重新导入了依赖关系。

闾丘淇
2023-03-14

问题在于generateAsync,在您的例子中,它在执行时生成GreetingServiceAsync。Eclipse可能没有配置为正确处理它,并且没有生成此类,Eclipse报告了缺少类警告。

另一个可以做的事情,让项目的工作是运行mvn包从命令行和添加生成的dir在目标dir作为源dir在eclipse(vie右键单击项目并选择新建-

此外,在执行mvn清理后,您可能会遇到相同的问题-生成的GreetingServiceAsync将被删除,问题可能会再次出现。

这个问题的存在是因为eclipse没有与maven紧密集成,并且使用自己的构建系统来忽略您没有插件的maven目标。您可以做的是打开eclipse首选项

如果手动复制生成的类,则必须记住需要在需要时更新它,因为它是自动生成的。所以你失去了这种便利。

后源
2023-03-14

我在win32计算机上做了另一次尝试,即使我在我的win32计算机上设置了上述环境,问题仍然出现。

所以我真的很困惑,就像Klarki说的,我必须做一些调整才能让它工作。我通过mvn gwt:generateAsync生成了GreetingServiceAsync,然后手动将GreetingServiceAsync复制到源文件夹,然后删除

可悲的是,它没有明智地发挥作用。

 类似资料:
  • 主要内容:导入 Maven 项目我们知道,m2eclipse 是一个在 Eclipse 中集成 Maven 的插件,通过该插件我们可以很轻松的在 Eclipse 中导入 Maven 项目,本节我们将讲解如何使用 Eclipse 导入 Maven 项目。 导入 Maven 项目 相比新建 Maven 项目,实际工作中使用更多的是将现有的 Maven 项目导入 Eclipse,具体步骤如下。 1)点击菜单栏中的 Import ,开始

  • 主要内容:IDEA 导入Maven 项目IntelliJ IDEA 是当前最流行的 Java IDE(集成开发环境)之一,也是业界公认最好用的 Java 开发工具之一。IntelliJ IDEA 支持 Maven 的全部功能,通过它我们可以很轻松地将 Maven 项目导入到 IDEA 中。 本节我们以 IntelliJ IDEA 2020.3.3 为例,详细介绍如何在 IntelliJ IDEA 中导入 Maven 项目。 IDEA 导

  • null null 我已经搜索了一些这些错误,有些人说删除“.settings”和“.project”文件可以消除这些错误,但这对我不起作用。 什么可能导致这些错误?有没有解决方法?

  • 当我尝试导入现有的maven项目时,Eclipse有一个奇怪的行为,它是一个多模块的JEE maven项目,包含父模块和子模块。结构svn如下所示: 父级 当我将项目导入Eclipse时,它会自动在“父”项目的同一目录中创建一个“共享库EAR”。导入后看起来像这样: 共享图书馆EAR 它对工作区中的每个“jar”maven项目都这样做。这很正常吗?我使用Eclipse氧气。2和Eclipse Ne

  • 我习惯于使用Maven分发项目,通常,团队中的每个人(以及CI服务器)都可以依赖Maven进行打包、测试、运行等调试,但是,项目可以导入到Eclipse并通过主类启动(与Eclipse的Maven插件相反)。Spring-Boot就是一个很好的例子。导入这样的项目后,我可以只运行或调试主类。 然而,对于JavaFX11来说,编写一个配置所有必要依赖关系的pom.xml似乎很有效,但是当我将这样一个