确定稳定的 Spring Cloud 相关环境版本

开发部署 Spring Cloud 微服务框架,需要先确定 Spring Cloud 的相关环境版本,主要包含:Spring Cloud、Spring Cloud Netflix、JDK、JRE、Java Version等相关版本,以及环境的配置。

现在最新版本 Java 10、Spring Boot 2.0、Spring Cloud Finchley.M9,但这些版本还不太稳定,而且相关的兼容也不是很好,问题的解决方案也比较少。

今天花了大概一天的时间,尝试了各种版本的兼容,以及使用部署的问题,最终确定了下面这套版本,比较相对稳定。

  • Spring Cloud:Edgware.SR3(http://projects.spring.io/spring-cloud/),和 Spring Boot 版本关联,可在官网进行查看。
  • Spring Cloud Netflix:1.4.4.RELEASE
  • Spring Boot:1.5.10.RELEASE
  • JDK:Java SE Development Kit 8u162(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html),也就是 jdk1.8.0_162。
  • JRE:Server JRE (Java SE Runtime Environment) 8u161(http://www.oracle.com/technetwork/java/javase/downloads/server-jre8-downloads-2133154.html)
  • Java Version:1.8,和 JDK 对应

如果使用其他版本的话,会出现一些问题,比如下面:

  • SpringCloud异常(Euruka):Application run failed java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder
  • How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9
  • com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
  • java.lang.NoClassDefFoundError: javax/activation/DataHandler
  • Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat

服务器配置 JRE 环境

使用 wget 命令,在官网下载对应的 Server JRE。

创建安装目录:

$ sudo mkdir -p /usr/local/java

解压文件到指定目录:

$ sudo tar -zxvf serverjre-9.0.1_linux-x64_bin.tar.gz -C /usr/local/java/ --strip-components=1

编辑配置文件:

$ sudo vi /etc/profile

将下面配置添加到配置文件中:

# JRE configuration

export JAVA_HOME=/usr/local/java
export JRE_HOME=${JAVA_HOME}
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

# End JDK configuration

生效及测试:

$ source /etc/profile
$ java -version

Mac 配置 JDK 环境

在官网下载对应的 Mac JDK 版本。

直接安装成功后(目录:/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk)。

编辑配置文件:

$ sudo vi /etc/profile

将下面配置添加到配置文件中:

# JDK configuration

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
export JRE_HOME=${JAVA_HOME}
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

# End JDK configuration

生效及测试:

$ source /etc/profile
$ java -version

IntelliJ IDEA 选择添加 JDK 即可:

确定稳定的 Spring Cloud 相关环境版本_第1张图片

IntelliJ IDEA 修改当前项目的 JDK 版本:

确定稳定的 Spring Cloud 相关环境版本_第2张图片

参考资料:https://card.weibo.com/article/v3/editor#/history/186963
https://card.weibo.com/article/v3/editor#/history/186608
https://card.weibo.com/article/v3/editor#/history/186424
https://card.weibo.com/article/v3/editor#/history/185801
https://card.weibo.com/article/v3/editor#/history/185781
https://card.weibo.com/article/v3/editor#/history/185463
https://card.weibo.com/article/v3/editor#/history/174288
https://card.weibo.com/article/v3/editor#/history/174119
https://card.weibo.com/article/v3/editor#/history/173561
https://card.weibo.com/article/v3/editor#/history/173336
https://card.weibo.com/article/v3/editor#/history/173082
https://card.weibo.com/article/v3/editor#/history/184630
https://card.weibo.com/article/v3/editor#/history/183057
https://card.weibo.com/article/v3/editor#/history/184940
https://card.weibo.com/article/v3/editor#/history/186882
https://card.weibo.com/article/v3/editor#/history/186884
https://card.weibo.com/article/v3/editor#/history/186966
https://card.weibo.com/article/v3/editor#/history/187201
https://card.weibo.com/article/v3/editor#/history/187391
https://card.weibo.com/article/v3/editor#/history/174940
https://card.weibo.com/article/v3/editor#/history/187695
https://card.weibo.com/article/v3/editor#/history/185492
https://card.weibo.com/article/v3/editor#/history/187410
https://card.weibo.com/article/v3/editor#/history/174972
https://card.weibo.com/article/v3/editor#/history/187714
https://card.weibo.com/article/v3/editor#/history/185531
https://card.weibo.com/article/v3/editor#/history/188021
https://card.weibo.com/article/v3/editor#/history/175465
https://card.weibo.com/article/v3/editor#/history/187712
https://card.weibo.com/article/v3/editor#/history/188523
https://card.weibo.com/article/v3/editor#/history/188120
https://card.weibo.com/article/v3/editor#/history/176032
https://card.weibo.com/article/v3/editor#/history/176073
https://card.weibo.com/article/v3/editor#/history/176022
https://card.weibo.com/article/v3/editor#/history/188239
https://card.weibo.com/article/v3/editor#/history/188643
https://card.weibo.com/article/v3/editor#/history/186373
https://card.weibo.com/article/v3/editor#/history/188251
https://card.weibo.com/article/v3/editor#/history/188665
https://card.weibo.com/article/v3/editor#/history/186385
https://card.weibo.com/article/v3/editor#/history/186508
https://card.weibo.com/article/v3/editor#/history/188788
https://card.weibo.com/article/v3/editor#/history/188382
https://card.weibo.com/article/v3/editor#/history/186627
https://card.weibo.com/article/v3/editor#/history/176292
https://card.weibo.com/article/v3/editor#/history/176523
https://card.weibo.com/article/v3/editor#/history/188817
https://card.weibo.com/article/v3/editor#/history/188818
https://card.weibo.com/article/v3/editor#/history/189232
https://card.weibo.com/article/v3/editor#/history/189237
https://card.weibo.com/article/v3/editor#/history/186919
https://card.weibo.com/article/v3/editor#/history/186921
https://card.weibo.com/article/v3/editor#/history/176408
https://card.weibo.com/article/v3/editor#/history/188683
https://card.weibo.com/article/v3/editor#/history/189175
https://card.weibo.com/article/v3/editor#/history/186813
https://card.weibo.com/article/v3/editor#/history/176522
https://card.weibo.com/article/v3/editor#/history/176562
https://card.weibo.com/article/v3/editor#/history/188886
https://card.weibo.com/article/v3/editor#/history/189283
https://card.weibo.com/article/v3/editor#/history/186984
https://card.weibo.com/article/v3/editor#/history/188906
https://card.weibo.com/article/v3/editor#/history/176578
https://card.weibo.com/article/v3/editor#/history/189299
https://card.weibo.com/article/v3/editor#/history/189300
https://card.weibo.com/article/v3/editor#/history/187004
https://card.weibo.com/article/v3/editor#/history/187005
https://card.weibo.com/article/v3/editor#/history/176613
https://card.weibo.com/article/v3/editor#/history/176614
https://card.weibo.com/article/v3/editor#/history/176687
https://card.weibo.com/article/v3/editor#/history/176692
https://card.weibo.com/article/v3/editor#/history/189480
https://card.weibo.com/article/v3/editor#/history/189482
https://card.weibo.com/article/v3/editor#/history/189063
https://card.weibo.com/article/v3/editor#/history/189067
https://card.weibo.com/article/v3/editor#/history/176713
https://card.weibo.com/article/v3/editor#/history/187171
https://card.weibo.com/article/v3/editor#/history/189622
https://card.weibo.com/article/v3/editor#/history/189624
https://card.weibo.com/article/v3/editor#/history/187236
https://card.weibo.com/article/v3/editor#/history/187237
https://card.weibo.com/article/v3/editor#/history/176714
https://card.weibo.com/article/v3/editor#/history/176820
https://card.weibo.com/article/v3/editor#/history/188223
https://card.weibo.com/article/v3/editor#/history/188226
https://card.weibo.com/article/v3/editor#/history/189694
https://card.weibo.com/article/v3/editor#/history/190006
https://card.weibo.com/article/v3/editor#/history/177134
https://card.weibo.com/article/v3/editor#/history/177135
https://card.weibo.com/article/v3/editor#/history/189554
https://card.weibo.com/article/v3/editor#/history/189556
https://card.weibo.com/article/v3/editor#/history/189637
https://card.weibo.com/article/v3/editor#/history/188465
https://card.weibo.com/article/v3/editor#/history/190067
https://card.weibo.com/article/v3/editor#/history/177250
https://card.weibo.com/article/v3/editor#/history/188810
https://card.weibo.com/article/v3/editor#/history/190213
https://card.weibo.com/article/v3/editor#/history/177397

你可能感兴趣的:(确定稳定的 Spring Cloud 相关环境版本)