本文介绍了为非默认模块选择本地开发服务器上的特定端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 build.gradle 文件中,我将以下配置用于我的非默认(module2)AppEngine gradle 模块:

In my build.gradle file, I use the following config for my non-default (module2) AppEngine gradle module:

appengine {
    downloadSdk = true
    httpAddress = "0.0.0.0"
    httpPort = 8081
    appcfg {
        email = "[email protected]"
        oauth2 = true
    }
}

但是,当我运行Google AppEngine 配置"时,该模块仍然在 some_random_port 上启动,而不是在 8081 上启动.我想修复这些运行的端口,因此我可以依赖这些端口我在本地开发服务器上运行测试请求时的端口.

However, when I run my "Google AppEngine configuration", the module still starts on some_random_port instead of on 8081. I want to fix the ports that these run on, so I can rely on those ports when I run test requests on my local development server.

我做错了什么?还是只是不支持?

What am I doing wrong? Or is this just not supported?

======================================================================Appengine 模块结构:

======================================================================Appengine modules structure:

- root( apply java, ear, appengine)
  - default (apply java, war, appengine) - needs to run on 8080 on local dev server
  - module2 (apply java, war, appengine) - needs to run on 8081 on local dev server

Appengine 版本:1.9.22

Appengine version: 1.9.22

Gradle Appengine 插件版本:1.9.21

Gradle Appengine plugin version: 1.9.21

编辑:

我还尝试在其自己的Appengine 运行配置"中运行每个模块,虽然这些模块确实在各自的端口中运行,但我无法再在它们之间进行通信.尝试从默认模块上的 servlet 在 module2 上安排任务会出现以下错误:

I also tried running each module in its own "Appengine run configuation" and while the modules do run in their respective ports, I can no longer communicate between them. Trying to schedule a task on module2 from a servlet on default module gives the following error:

com.google.appengine.api.modules.ModulesException: Unknown module
    at com.google.appengine.api.modules.ModulesServiceImpl$ModulesServiceFutureWrapper.convertApplicationException(ModulesServiceImpl.java:365)
    at com.google.appengine.api.modules.ModulesServiceImpl$ModulesServiceFutureWrapper.convertException(ModulesServiceImpl.java:352)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:96)
    at com.google.appengine.api.modules.ModulesServiceImpl.getAsyncResult(ModulesServiceImpl.java:104)
    at com.google.appengine.api.modules.ModulesServiceImpl.getDefaultVersion(ModulesServiceImpl.java:163)

推荐答案

@crazystick 为 Maven 回答了这个问题.这是为 Gradle 重新完成的相同解决方案:

@crazystick answered it for Maven. Here's the same solution re-done for Gradle:

apply plugin: ear

...

appengine {
    downloadSdk = true
    httpAddress = "0.0.0.0"
    jvmFlags = ['-Dcom.google.appengine.devappserver_module.default.port=8080',
                '-Dcom.google.appengine.devappserver_module.module1.port=8081']
    appcfg {
        email = "[email protected]"
        oauth2 = true
    }
}

这篇关于为非默认模块选择本地开发服务器上的特定端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:26