简体   繁体   English

Google App Engine 是否支持 Java 8?

[英]Does Google App Engine support Java 8?

Trying to get started with Google App Engine - does it work with Java 8?尝试开始使用 Google App Engine - 它是否适用于 Java 8?

I've followed the instructions on this page: https://console.developers.google.com/start/appengine我已按照此页面上的说明进行操作: https : //console.developers.google.com/start/appengine

Selecting 'Java', I successfully completed the Maven build, but when I visit localhost:8080 nothing is running.选择“Java”,我成功完成了 Maven 构建,但是当我访问 localhost:8080 时没有任何运行。

The instructions say "make sure you have Java 7 JDK installed" however I have just installed Java 8 JDK.说明说“确保您安装了 Java 7 JDK”,但是我刚刚安装了 Java 8 JDK。

Do I need to separately install Apache?我需要单独安装Apache吗?

Java 8 is now generally available on App Engine Standard Environment , joining the GA runtime on the App Engine Flexible Environment. Java 8 现在在 App Engine Standard Environment 上普遍可用,加入了 App Engine 柔性环境上的 GA 运行时。

Learn about the differences .了解差异

The new Java 8 runtime has all the benefits of Java 7 but with upgrades and enhancements:新的 Java 8 运行时具有 Java 7 的所有优点,但具有升级和增强功能:

  • OpenJDK 8-based Java runtime supports the standard public Java library (no whitelist)基于 OpenJDK 8 的 Java 运行时支持标准的公共 Java 库(无白名单)
  • Doesn't impose a security manager--your code won't be restricted by Java permissions issues.不强加安全管理器——您的代码不会受到 Java 权限问题的限制。

Not at the time of writing but you can keep track of the status in this issue:不是在撰写本文时,但您可以跟踪此问题的状态:

[The passage of time has changed the 'no' from this accepted answer to 'yes'. [随着时间的推移,这个公认的答案的“不”变成了“是”。 Please see others answers below.]请参阅下面的其他答案。]

Short answer, no.简短的回答,没有。 They will integrate it over time, but for now if you use it, it will cause you a lot of errors.他们会随着时间的推移集成它,但是现在如果你使用它,它会给你带来很多错误。 I would recommend against it我会建议反对它

Also take note of user7610's answer below :).还要注意下面 user7610 的回答:)。 It is as of now the only way to have Java 8 on the Cloud Platform这是目前在云平台上安装 Java 8 的唯一方法

Update: it is available in the "standard" (sandboxed) offering since mid 2017, https://cloud.google.com/blog/products/gcp/java-8-on-app-engine-standard-environment-is-now-generally-available更新:自 2017 年年中以来,它在“标准”(沙盒)产品中可用, https://cloud.google.com/blog/products/gcp/java-8-on-app-engine-standard-environment-is-现在普遍可用

Before then, it was sort-of available, via Managed VMs.在此之前,它可以通过托管虚拟机获得。 The idea is that you provide a Docker container with whatever software you need (like Java 8) and GAE will use that as your app instance VMs.这个想法是您提供一个 Docker 容器,其中包含您需要的任何软件(如 Java 8),GAE 将使用它作为您的应用程序实例虚拟机。 You still get the autoscaling, monitoring and all that.您仍然可以获得自动缩放、监控等功能。

The disadvantage of Managed VMSs is that you are charged as for the Compute Engine VMs.托管 VMS 的缺点是您需要按 Compute Engine 虚拟机收费。 That means you pay by minute and there is no free quota.这意味着您按分钟付费,并且没有免费配额。 There is the $300 credit for new user accounts for 60 days, but after that you'd have to pay.新用户帐户有 60 天的 300 美元信用额度,但之后您必须付款。

If your interest is in using lambda expressions on Google App Engine, you could give Retrolambda a try.如果您对在 Google App Engine 上使用 lambda 表达式感兴趣,可以尝试一下Retrolambda I haven't tried it yet, but it claims to backport Java 8 lambda expressions to Java 7.我还没有尝试过,但它声称将 Java 8 lambda 表达式向后移植到 Java 7。

Google App Engine Java 8 支持从 2017 年第 3 季度开始全面提供。https://cloud.google.com/appengine/docs/standard/java/runtime-java8

yes it does.是的,它确实。 We just launched this to Beta and soon GA.我们刚刚将其发布到 Beta 版,并很快发布到 GA。

https://cloudplatform.googleblog.com/2017/06/Google-App-Engine-standard-now-supports-Java-8.html https://cloudplatform.googleblog.com/2017/06/Google-App-Engine-standard-now-supports-Java-8.html

App Engine Standard Java now supports Java8. App Engine 标准 Java 现在支持 Java8。 See the Beta documentation at: Java8 on GAE Standard documentation请参阅位于以下位置的 Beta 文档: Java8 on GAE 标准文档

Thanks谢谢

It's not quite the same thing, but you can use Java 8 with the new App Engine " flexible environment ".这并不完全相同,但您可以将 Java 8 与新的 App Engine“灵活环境”一起使用。 I don't think you can access App Engine APIs (such as the images service or task queues) but you'll be able to use services which live outside of App Engine, such as the Datastore and Pub/Sub.我认为您无法访问 App Engine API(例如图像服务或任务队列),但您可以使用 App Engine 之外的服务,例如 Datastore 和 Pub/Sub。

It's also worth bearing in mind that the service is currently in beta (so not covered by any SLAs).还值得记住的是,该服务目前处于测试阶段(因此未包含在任何 SLA 中)。 Also, the pricing is different ;此外,定价不同 instead of using the normal App Engine pricing structure, it's based on usage of GCE virtual machines.它不是使用正常的 App Engine 定价结构,而是基于 GCE 虚拟机的使用情况。

<runtime>java8</runtime>到您的 appengine-web.xml 文件。

Yes, using App Engine flexible environment.是的,使用 App Engine 柔性环境。 Here are the official docs: https://cloud.google.com/appengine/docs/flexible/java/以下是官方文档: https : //cloud.google.com/appengine/docs/flexible/java/

And here is the github repo for this implementation: https://github.com/GoogleCloudPlatform/appengine-java-vm-runtime这是此实现的 github 存储库: https : //github.com/GoogleCloudPlatform/appengine-java-vm-runtime

您显然可以使用 JDK8 来创建 JRE7 兼容的字节码,这似乎是 Google 推荐的: https ://cloud.google.com/appengine/docs/standard/java/download

-source 1.7 -target 1.7

Yes, You can use flexible environment.是的,您可以使用灵活的环境。 and change setting of your app.yaml并更改您的app.yaml设置

vm: true

for more information study https://cloud.google.com/appengine/docs/flexible/有关更多信息,请研究https://cloud.google.com/appengine/docs/flexible/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM