zoukankan      html  css  js  c++  java
  • Spring boot

    1. springboot 项目启动就闪退(解决方案)

       父项目中缺少web依赖:

    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    

    2. 在使用 SPRING INITIALIZR 生成项目的时候,Dependencies 中选择 web,会自动生成上面的依赖,也可以解决上面的问题

    3. 只需要通过mvn spring-boot:run 命令就可以快速启动SpringBoot应用。

    4. 导入静态方法:import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

      批量导入静态方法:import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

    5. MockMvc - SpringMVC单元测试的独立测试:https://blog.csdn.net/kqZhu/article/details/78836275

    6. 谷歌浏览器中安装JsonView扩展程序

    7. spring boot 2 使用 actuator 404的问题:所有 endpoints 默认情况下都已移至 /actuator。就是多了跟路径 actuator,例如:/actuator/health

       health:现在有一个 management.endpoint.health.show-details 选项 neveralwayswhen-authenticated,而不是依靠 sensitive 标志来确定 health 端点是否必须显示全部细节。 默认情况下,/actuator/health公开并且不显示细节

       /autoconfig被替换成了conditions,敏感信息默认不显示,需要配置:management.endpoints.web.exposure.include: health,info,conditions

     参见:https://my.oschina.net/iyinghui/blog/1835220        https://blog.csdn.net/alinyua/article/details/80009435

    8. 服务存储的数据结构是双层的HashMap,且是线程安全的ConcurrentHashMap。具体实现在AbstractInstanceRegistry的成员变量registry:

        private final ConcurrentHashMap<String, Map<String, Lease<InstanceInfo>>> registr = new ConcurrentHashMap<String, Map<String, Lease<InstanceInfo>>>();

        第一层 key 是服务名称,第二层map key是 "ip:port"

        第一层的ConcurrentHashMap的key=spring.application.name,也就是应用名;value为ConcurrentHashMap。

        第二层的ConcurrentHashMap的key=instanceId,也就是服务的唯一实例ID,value为Lease对象,也就是具体的服务了。

        Lease其实是对InstanceInfo的包装,里面保存了实例信息以及一些实例服务注册相关的时间。如注册时间registrationTimestamp、最新的续约时间lastUpdateTimestamp等。

        InstanceInfo是具体的服务实例信息,里面保存了服务实例等详细信息。如instanceId、IP、port、健康检查URL等等。

        参见:http://www.majunwei.com/view/201808130944142253.html

    9. Eureka 客户端(消费者,生产者)主动从注册中心获取 注册列表(默认30秒)和 主动发起心跳 避免被注册中心剔除。

  • 相关阅读:
    google的开源项目总结
    Google Breakpad 完全解析(二) —— Windows前台实现篇
    Google Breakpad 完全解析(一) —— Windows入门篇
    PVS-Studio静态通用分析规则
    C,C++开源项目中的100个Bugs
    一日一点RakNet(3)--介绍
    C++开源跨平台类库集
    如何实现数组的随机排序?
    JavaScript原型,原型链 ? 有什么特点?
    js的基本数据类型
  • 原文地址:https://www.cnblogs.com/Jtianlin/p/10400316.html
Copyright © 2011-2022 走看看