Spring Cloud问题分析

  基于Spring Cloud框架开发时,经常会碰到各种开发问题,那么碰到这些问题时如何去解决呢?下面描述基于Spring Cloud问题定位的基本思路,大概可以分为如下几步:

  • 排查配置问题
  • 环境问题
  • 排查代码问题
  • 定位Spring-Cloud Bug

一、配置问题

   (1)配置属性错误

   配置属性错误包括:A.配置拼写错误;B.yaml缩进错误(yaml缩进错误可能会导致配置解析失败,甚至启动失败);

   (2)配置位置错误

    应写在bootstrap.yml中的配置写在了application.yml中

  • bootstrap.yml is loaded before application.yml
  • It is typically used for the following:
  1. when using Spring Cloud Config Server, you should specify spring.application.name and spring.cloud.config.server.git.uri inside bootstrap.yml
  2. some encryption/decryption information

    Technically, bootstrap.yml is loaded by a parent Spring ApplicationContext. That parent ApplicationContext is loaded before the one that uses application.yml

 参考:https://stackoverflow.com/questions/32997352/what-is-the-diference-between-putting-a-property-on-application-yml-or-bootstrap  

            https://stackoverflow.com/questions/37074642/settings-in-application-yml-for-spring-cloud-config-arent-used-when-app-is-exec

            https://juejin.im/entry/585788e1b123db00658219bd

二、环境问题

  (1)JAVA环境变量

  (2)Maven环境变更

  (3)Spring Boot/Spring Cloud环境变量

 (4)Spring Boot/Spring Cloud允许使用环境变量加载配置

三、Spring Cloud Bug

   如:spring-boot 自定义内置tomcat信息泄漏问题,参见:https://my.oschina.net/u/252181/blog/832562

原文地址:https://www.cnblogs.com/moonandstar08/p/7512409.html