4

我正在使用 Eclipse Java EE,当我localhost:8080在浏览器上编译和运行我的 Google AppEngine 项目时没有给出任何正确的输出,但是当我使用127.0.0.1:8080我的程序时,我的程序在浏览器上运行得很好。但是,当我将我的应用程序部署到谷歌应用程序点时,localhost:8080意志会更新并且运行良好(仅适用于我部署到应用程序点的实例)。

为什么localhost:8080不能正确更新和127.0.0.1:8080正确更新?

我不能127.0.0.1:8080总是使用 insted localhost 因为当我尝试获取_ah/api/explorerthen127.0.0.1:8080/_ah/api/explorer将重定向到 google api 资源管理器(而不是我的 api 资源管理器)。

我应该怎么做才能做到这一点?

4

2 回答 2

2

我会将此作为评论添加到已接受的答案中,但我还没有足够的声誉点。

上面的答案是 100% 正确的,但是以标志开头的替代方法是编辑 pom.xml。靠近我的底部是这个。我不得不取消注释“地址”行并且......魔术...... http://localhost:8080/再次开始工作。现在我只希望我能回到那三个小时。:D

<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    {snip}
    <configuration>
        {snip}
        <!-- Comment in the below snippet to bind to all -->
        <!-- IPs instead of just localhost -->
        <address>0.0.0.0</address>
        <port>8080</port>
        {snip}
     </configuration>
 </plugin>

这是我找到原件的地方。滚动到最底部:

https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-java-maven/blob/master/pom.xml

于 2015-04-13T04:25:01.890 回答
2

使用参数:

--address=...

用于服务器的主机地址。您可能需要设置此项以便能够从网络上的另一台计算机访问开发服务器。地址 0.0.0.0 允许本地主机访问和主机名访问。默认为本地主机。

更多关于这个here

于 2015-01-29T19:33:25.757 回答