如何在openshift上diy部署spring

昨天折腾了一天在openshift上diy支持spring-boot的环境,于是想终结一下也是给需要的朋友一个参考。

这篇文章中主要适用在openshift上部署了application后,在本地用eclipse继续开发的case,如果已经有一个现成的proj,只是需要部署上去的话,请参考本人的git 上的代码(https://github.com/RxCAI/openshift-diy-spring-boot-sample)这个sample原作者是kolorobot,因为我在开始尝试的时候发现它的配置中的maven mirror无法下载造成了部署错误,所以修改commit了他的代码。

下面进入正题:

一 如何在openshift上DIY一个支持spring-boot的环境

为什么要DIY?最重要的原因在于,目前openshift上现成的模版maven的版本太低,而spring-boot要求Maven 3.2+ or Gradle 1.12+。 所以要想部署spring-boot project到openshift上去,就一定要DIY。另外,现成的模版JDK还停留在7,所以如果需要8,也需要DIY。说完了why,接下来就是how了 ->

首先当然是安装openshift的rhcThe OpenShift Client tools, known asrhc。

具体步骤参考:https://developers.openshift.com/en/managing-client-tools.html

它的环境要求是Ruby 1.8.7 or + 以及 git

本人的系统是mac os x 10.8.5系统自带ruby 1.8.7及 git 1.8.5.2。

确认环境符合要求后,用命令行安装rhc

sudo gem install rhc

如果有问题的话官方建议run

sudo gem update 就是更新一下它的依赖库什么的。

但是,事情从来不是那么顺利,所以童话故事都是骗人的。。。

我遇到了和这位老兄一模一样的问题https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=1190896 虽然他是Linux的都是我的问题和他的几乎一模一样。

Description of problem:After installing rhc using `gem install rhc` on a RHEL 6.6 system, the following error is seen when running ‘rhc setup’:# rhc setup/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require’: /usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:236: syntax error, unexpected ‘.’, expecting kEND (SyntaxError).compact^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:462: odd number list for Hashtitle: @title,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:462: syntax error, unexpected ‘:’, expecting ‘}’title: @title,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:463: syntax error, unexpected ‘:’, expecting ‘=’percent_complete: percent_complete,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:464: syntax error, unexpected ‘:’, expecting ‘=’progress_bar: progress_bar,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:465: syntax error, unexpected ‘:’, expecting ‘=’step: @step,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:466: syntax error, unexpected ‘:’, expecting ‘=’steps_remaining: steps_remaining,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:467: syntax error, unexpected ‘:’, expecting ‘=’total_steps: @total_steps,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:468: syntax error, unexpected ‘:’, expecting ‘=’time_elapsed: ‘%0.2fs’ % time_elapsed,^/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:468: syntax error, unexpected ‘,’, expecting kEND/usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander/user_interaction.rb:470: syntax error, unexpected ‘}’, expecting kEND}.merge! @tokens^from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require’from /usr/lib/ruby/gems/1.8/gems/commander-4.3.0/lib/commander.rb:27from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require’from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require’from /usr/lib/ruby/gems/1.8/gems/rhc-1.34.2/lib/rhc.rb:30from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require’from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require’from /usr/lib/ruby/gems/1.8/gems/rhc-1.34.2/lib/rhc/cli.rb:1from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require’from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require’from /usr/lib/ruby/gems/1.8/gems/rhc-1.34.2/bin/rhc:18from /usr/bin/rhc:23:in `load’from /usr/bin/rhc:23Version-Release number of selected component (if applicable):rhc-1.34.2How reproducible:AlwaysSteps to Reproduce:1. Install ruby and rubygems on a RHEL-6.6 system2. Install rhc using `gem install rhc`3. Run any rhc commandAdditional info:# uname -r2.6.32-504.8.1.el6.x86_64# rpm -qa | grep rubyruby-1.8.7.374-3.el6_6.x86_64rubygems-1.8.24-6.el6op.noarchruby-libs-1.8.7.374-3.el6_6.x86_64# gem list*** LOCAL GEMS ***archive-tar-minitar (0.5.2)commander (4.3.0)highline (1.6.21)httpclient (2.6.0.1)net-scp (1.2.1)net-ssh (2.9.2)net-ssh-gateway (1.2.0)net-ssh-multi (1.2.0)open4 (1.3.4)rhc (1.34.2)Downgrading the ‘commander’ gem to 4.2.0 resolves the issue: # gem install commander -v 4.2.0既有美妙的风景,也会有称不上景只有风的地方。

如何在openshift上diy部署spring

相关文章:

你感兴趣的文章:

标签云: