【问题标题】:Could not find goal 'devmode' in plugin org.codehaus.mojo在插件 org.codehaus.mojo 中找不到目标“devmode”
【发布时间】:2018-02-07 18:34:11
【问题描述】:

我是 GWT 和 Maven 的初学者。我在 Eclipse 中创建了一个新的 GWT 应用程序项目。然后,我通过右键单击项目名称 => Configure => Convert to Maven Project 将该项目转换为 Maven 项目,我看到为此生成了一个 pom 文件项目。接下来,我作为 Maven 构建的项目运行,但它没有被编译,因为那里没有指定目标。实际上,我不明白在那个目标部分到底要写什么,因此,我在下面写了 package,然后我再次构建了 maven,它编译成功了。

之后,我尝试使用 设置新项目 部分下Run the GWT Project 中提到的第二步,在 SuperDevMode 的命令提示符中运行这个 maven 项目。但是,在命令提示符上执行这些步骤时,我收到了一个错误,即找不到 devmode。这是我的命令提示符日志:

C:\Users\TEST>cd eclipse-workspace/MyWebApp

C:\Users\TEST\eclipse-workspace\MyWebApp>mvn war:exploded
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenApp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-war-plugin:3.1.0:exploded (default-cli) @ abcdef ---
[INFO] Exploding webapp
[INFO] Assembling webapp [abcdef] in [C:\Users\TEST\eclipse-workspace\MyWebApp\target\abcdef-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [63 msecs]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.920 s
[INFO] Finished at: 2017-08-30T11:24:53+05:30
[INFO] Final Memory: 12M/107M
[INFO] ------------------------------------------------------------------------

C:\Users\TEST\eclipse-workspace\MyWebApp>mvn gwt:devmode
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.301 s
[INFO] Finished at: 2017-08-30T11:25:02+05:30
[INFO] Final Memory: 8M/107M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'devmode' in plugin org.codehaus.mojo:gwt-maven-plugin:2.8.1 among available goals clean, compile, compile-report, css, debug, eclipse, eclipseTest, generateAsync, help, i18n, mergewebxml, resources, run, run-codeserver, source-jar, test -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException

这是我的 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>MyWebApp</groupId>
  <artifactId>abcdef</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>test</testSourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <name>MavenApp</name>
  <description>It is a maven app</description>
</project>

我进行了很多搜索以解决此错误,但没有找到该问题的解决方案。请帮助我解决此问题,因为我对如何解决它感到非常困惑。

编辑:经过进一步研究,我使用mvn gwt:run 作为命令mvn gwt:devmode 的替代,但在命令提示符下仍然出现另一个错误,如下所示:

[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run (default-cli) on project MyWebApp: The parameters 'runTarget' for goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run are missing or invalid

【问题讨论】:

    标签: java eclipse maven gwt command-prompt


    【解决方案1】:

    如果没有比gwt:devmode 更多的信息,Maven 将尝试根据其默认设置找到合适的插件。碰巧有一个 gwt-maven-pluginorg.codehaus.mojo 作为 groupId,适合 Maven 内置插件解析。

    但这不是你要找的插件。

    您可能正在尝试使用this one,因此只需将其添加到您的pom.xml 中的&lt;plugins&gt; 部分:

    <plugin>
      <groupId>net.ltgt.gwt.maven</groupId>
      <artifactId>gwt-maven-plugin</artifactId>
      <version>1.0-rc-8</version>
      <extensions>true</extensions>
      <configuration>
        <moduleName>com.example.app.App</moduleName>
      </configuration>
    </plugin>
    

    根据需要调整 moduleName

    【讨论】:

      【解决方案2】:

      好吧,我能够通过将一些依赖项、插件和配置从 pom.xml 文件(在 webAppCreator 使用 maven 创建的项目中生成)复制到我项目的 pom.xml 文件中来解决这个问题在 Eclipse 中创建。所以,这是我最终创建的 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>MyPersonalProject</groupId>
        <artifactId>MyPersonalProject</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <properties>
      
          <!-- Setting maven.compiler.source to something different to 1.8
               needs that you configure the sourceLevel in gwt-maven-plugin since
               GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) -->
          <maven.compiler.source>1.8</maven.compiler.source>
          <maven.compiler.target>1.8</maven.compiler.target>
      
          <!-- Don't let your Mac use a crazy non-standard encoding -->
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        </properties>
        <dependencyManagement>
          <dependencies>
            <!-- ensure all GWT deps use the same version (unless overridden) -->
            <dependency>
              <groupId>com.google.gwt</groupId>
              <artifactId>gwt</artifactId>
              <version>2.8.1</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>
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
          <sourceDirectory>src</sourceDirectory>
          <testSourceDirectory>test</testSourceDirectory>
          <resources>
            <resource>
              <directory>src</directory>
              <excludes>
                <exclude>**/*.java</exclude>
              </excludes>
            </resource>
          </resources>
          <plugins>
          <plugin>
              <groupId>net.ltgt.gwt.maven</groupId>
              <artifactId>gwt-maven-plugin</artifactId>
              <version>1.0-rc-6</version>
              <executions>
                <execution>
                  <goals>
                    <goal>import-sources</goal>
                    <goal>compile</goal>
                    <goal>import-test-sources</goal>
                    <goal>test</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <moduleName>mypackage.MyPersonalproject</moduleName>
                <failOnError>true</failOnError>
                <!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use
                     a different source language for java compilation -->
                <sourceLevel>1.8</sourceLevel>
                <!-- Compiler configuration -->
                <compilerArgs>
                  <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
                  <arg>-compileReport</arg>
                  <arg>-XcompilerMetrics</arg>
                </compilerArgs>
                <!-- DevMode configuration -->
                <warDir>${project.build.directory}/${project.build.finalName}</warDir>
                <classpathScope>compile+runtime</classpathScope>
                <!-- URL(s) that should be opened by DevMode (gwt:devmode). -->
                <startupUrls>
                  <startupUrl>MyPersonalProject.html</startupUrl>
                </startupUrls>
              </configuration>
            </plugin>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.6.1</version>
              <configuration>
                <source>1.8</source>
                <target>1.8</target>
              </configuration>
            </plugin>
          </plugins>
        </build>
      </project>
      

      当我在命令提示符中使用 maven 运行此应用程序时,它运行成功,除了在命令提示符日志中显示 2 或 3 个警告。另外,我注意到版本中生成的 SNAPSHOT 与 Eclipse 创建的 pom.xml 与命令提示符下的 maven 项目创建的相比是不同的。

      【讨论】:

        猜你喜欢
        • 2016-04-18
        • 2016-12-28
        • 2017-01-31
        • 2013-07-19
        • 2018-04-13
        • 1970-01-01
        • 1970-01-01
        • 2017-05-21
        • 2021-06-27
        相关资源
        最近更新 更多