CloudFoundry和JDK [英] CloudFoundry and JDK
问题描述
我正在努力部署需要在运行时编译Java代码的spring应用程序。当用户提交问题解决方案时,我的应用程序会调用javac命令,以便以后可以运行Java
I'm struggling with the deployment of a spring app that needs to compile java code during runtime. My app calls the javac command when a user submits a solution to a problem, so it can later run java
我正在部署到Cloud Foundry并使用java-buildpack,但不幸的是,它不是JDK附带的,只有JRE是可用的,而且那东西没有javac或java命令。
I'm deploying to cloud foundry and using the java-buildpack, but unfortunately, it doesn't come with JDK, only JRE is available and that thing has no javac or java commands available.
你们知道如何将JDK添加到云代工厂的方法吗?
Do you guys know a way on how to add JDK to cloud foundry, without having to write my own custom buildpack.
谢谢
推荐答案
我建议您使用多构建包支持,并使用apt-buildpack安装JDK。它应该与JBP一起正常工作。
I would suggest you use multi-buildpack support and use the apt-buildpack to install a JDK. It should work fine alongside the JBP. It just needs to be first in the list.
https://github.com/cloudfoundry/apt-buildpack
示例:
-
创建apt.yml。
Create an apt.yml.
---
packages:
- openjdk-11-jdk-headless
将其捆绑到您的JAR中, jar uf path / to / your / file.jar apt.yml
。应该将其添加到JAR的根目录中,因此,如果您 jar tf path / to / your / file.jar
,您应该只会看到 apt。 yml
并没有前缀。
Bundle that into your JAR, jar uf path/to/your/file.jar apt.yml
. It should be added to the root of the JAR, so if you jar tf path/to/your/file.jar
you should see just apt.yml
and nothing prefixed to it.
更新manifest.yml。在列表中首先添加apt-buildpack。
Update your manifest.yml. Add the apt-buildpack first in the list.
---
applications:
- name: spring-music
memory: 1G
path: build/libs/spring-music-1.0.jar
buildpacks:
- https://github.com/cloudfoundry/apt-buildpack#v0.2.2
- java_buildpack
然后 cf push
。您应该看到apt-buildpack运行并安装JDK。然后将其安装在〜/ deps / 0 / lib / jvm / java-11-openjdk-amd64
下。它似乎也不以PATH结尾,因此请使用完整路径 javac
或更新路径。
Then cf push
. You should see the apt-buildpack run and install the JDK. It'll then be installed under ~/deps/0/lib/jvm/java-11-openjdk-amd64
. It does not appear to end up on the PATH either, so use a full path to javac
or update the path.
这篇关于CloudFoundry和JDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!