试图在Rails Heroku应用程序上安装Java [英] Trying to install Java on a Rails Heroku app

查看:167
本文介绍了试图在Rails Heroku应用程序上安装Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Rails应用程序依靠遗留Java代码来实现其逻辑。它通过shell命令运行代码: javac whatever 然后 java whatever 。但是,在部署到Heroku之后,请求失败,因为它找不到 javac java



在Rails应用程序中安装Java的最佳方式是什么?我尝试使用一个多buildpack解决方案,用这个.buildpacks:

  https://github.com/heroku/heroku- buildpack-ruby.git 
https://github.com/heroku/heroku-buildpack-java.git

但是我得到这个错误:

  =====>下载Buildpack:https://github.com/heroku/heroku-buildpack-java.git 

!推送被拒绝,未能编译Multipack应用程序

我试着分支Ruby buildpack并直接从那里安装Java,但我真的不知道我在做什么。任何想法?

解决方案

尝试使用 heroku-buildpack-jvm-common 而不是Java buildpack。因此,您的 .buildpacks 文件将如下所示:

  https:/ /github.com/heroku/heroku-buildpack-jvm-common.git 
https://github.com/heroku/heroku-buildpack-ruby.git

将JVM放在Ruby之前,以防止 javac 或<$ c在编译/构建时需要$ c> java 。



JVM buildpack基本上与Java buildpack相同,但不安装Maven,因此不需要 pom.xml 文件。缺少的 pom.xml 就是为什么您会收到我认为的错误。



编辑



在现代时代,您还可以运行:

  $ heroku buildpacks:添加heroku / jvm 
$ heroku buildpacks:add heroku / ruby​​


My Rails app relies on legacy Java code for a piece of its logic. It runs the code via shell commands: javac whatever and then java whatever. However, after deploying to Heroku, the request fails because it can't locate javac or java.

What's the best way to install Java in a Rails app? I tried using a multi-buildpack solution, with this .buildpacks:

https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/heroku/heroku-buildpack-java.git

But I get this error:

=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-java.git

 !     Push rejected, failed to compile Multipack app

I tried forking the Ruby buildpack and installing Java directly from there, but I don't really know what I'm doing. Any ideas?

解决方案

Try using heroku-buildpack-jvm-common instead of the Java buildpack. So your .buildpacks file will look like this:

https://github.com/heroku/heroku-buildpack-jvm-common.git
https://github.com/heroku/heroku-buildpack-ruby.git

It's probably a good idea to put the JVM one before the Ruby one in case javac or java are needed at compile/build time.

The JVM buildpack is essentially the same as the Java buildpack, but doesn't install Maven and thus does not require a pom.xml file. The missing pom.xml is why you got that error I think.

EDIT

In the modern era, you can also run:

$ heroku buildpacks:add heroku/jvm
$ heroku buildpacks:add heroku/ruby

这篇关于试图在Rails Heroku应用程序上安装Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆