【问题标题】:Could not find goal 'run' in plugin com.google.appengine:appengine-maven-plugin在插件 com.google.appengine:appengine-maven-plugin 中找不到目标“运行”
【发布时间】:2017-05-21 13:18:31
【问题描述】:

我正在构建一个 Maven 应用程序,我想用 Java 将它部署在 Google 应用程序引擎上。

我想在本地服务器上测试localhost:8080

当我运行命令mvn clean package 时,它会给我一个构建成功提示,如下所示

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.284 s
[INFO] Finished at: 2017-01-06T12:32:58-05:00
[INFO] Final Memory: 29M/400M
[INFO] ------------------------------------------------------------------------

但是当我运行命令mvn appengine:run 时,它给了我这个错误信息:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.259 s
[INFO] Finished at: 2017-01-06T12:33:03-05:00
[INFO] Final Memory: 8M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'run' in plugin com.google.appengine:appengine-maven-plugin:1.9.48 among available goals backends_configure, backends_delete, backends_rollback, backends_start, backends_stop, backends_update, create-property, debug, devserver, devserver_start, devserver_stop, endpoints_get_client_lib, endpoints_get_discovery_doc, endpoints_get_swagger_doc, enhance, migrate_traffic, rollback, set_default_version, start_module_version, stop_module_version, update, update_cron, update_dispatch, update_dos, update_indexes, update_queues, vacuum_indexes -> [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 文件中添加了来自 appengine 骨架架构类型的插件

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

我还将版本更改为云 maven 文档中的版本

<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>gcloud-maven-plugin</artifactId>
    <version>1.9.48</version>
    <configuration>
        <set_default>true</set_default>
    </configuration>
</plugin>

我仍然收到上述错误。

我猜我缺少一些插件。我想知道如何在本地运行我的应用程序以及制作mvn appengine:run work 缺少什么

编辑

现在有了下面给出的修复,我得到了这个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project java-adwords: Compilation failure
[ERROR] /home/seraf/java-adwords-maven/java-adwords/src/main/java/myApp/adwords_axis/MainApp.java:[11,19] doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in adwords_axis.MainApp cannot override doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) in javax.servlet.http.HttpServlet
[ERROR] overridden method does not throw java.lang.Exception
[ERROR] -> [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/MojoFailureException

但这是我的 java 主代码,它会抛出异常:

      public void doGet(HttpServletRequest request, HttpServletResponse response)                                                                              
          throws Exception {                                                    

          response.setContentType("text/plain");                                
          response.getWriter().println("Test");                                 
          run();                                                                

      }  

【问题讨论】:

    标签: java eclipse maven google-app-engine google-cloud-platform


    【解决方案1】:

    找不到目标run,因为插件没有这样的目标。我相信您正在寻找appengine:devserver。请参阅Using Apache Maven and the App Engine Plugin 中的使用开发服务器测试您的应用部分。

    关于您在上面的编辑中显示的第二个问题。答案是神秘的,指向抛出异常的问题。你重写的方法必须抛出相同的异常,不仅是IOException,还有ServletException

    在使用更复杂的库(例如 javax.servlet.*)时,最好让您的 IDE 创建方法存根以避免这些类型的错误。不过,我有点惊讶它一开始没有发出警告或错误。

    【讨论】:

      【解决方案2】:

      根据 Google App Engine 文档,您可以使用两个插件处理 App Engine maven 命令:

      如果你想使用基于appcfg的那个,使用下面的插件

      <plugin>
          <groupId>com.google.appengine</groupId>
          <artifactId>gcloud-maven-plugin</artifactId>
          <version>1.9.48</version>
          <configuration>
              <set_default>true</set_default>
          </configuration>
      </plugin>
      

      本地服务器和部署的命令是

       - mvn appengine:devserver
       - mvn appengine:update
      

      如果你想使用基于Gloud SDK的那个,使用下面的插件

      <plugin>
          <groupId>com.google.cloud.tools</groupId>
          <artifactId>appengine-maven-plugin</artifactId>
          <version>1.0.0</version>
      </plugin>
      

      本地服务器和部署的命令是

       - mvn appengine:run
       - mvn appengine:deploy
      

      如果您想同时使用这两个插件,您可能需要使用以下命令:

       - mvn com.google.appengine:appengine-maven-plugin:devserver
       - mvn com.google.appengine:appengine-maven-plugin:update
       - mvn com.google.cloud.tools:appengine-maven-plugin:run
       - mvn com.google.cloud.tools:appengine-maven-plugin:deploy
      

      (正如thread 中所建议的那样)

      您还可以在此thread 中找到更多信息

      【讨论】:

        猜你喜欢
        • 2019-04-06
        • 2014-12-09
        • 2016-06-21
        • 2021-06-27
        • 1970-01-01
        • 2019-01-17
        • 1970-01-01
        • 2021-10-30
        • 2018-10-17
        相关资源
        最近更新 更多