springboot
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
spring能做什么
微服务microservice 响应式编程reactive 分布式云开发cloud web开发 无服务开发serverless 事件驱动 event driver batch 批处理
spring5重大升级 :响应式编程 少量资源处理大量并发 匹配jdk8接口的默认实现 源码上有升级
springboot makeit easy to create stand-alone,producti-grade spring based app that you can “just run”即 快速创建出生产级别的spring应用 是整合spring技术栈的一站式框架 是简化spring技术栈的快速开发脚手架
springboot优点特点
使用嵌入式的web服务器如tomcat 目标环境则不需要
提供自动stater依赖 不需要导入jar包 只需要导入一个依赖web-starter 也不需要考虑版本问题
自动配置spring 第三方功能如数据库等
提供生产级别的监控和健康检查,还有外部化配置,只需要在外部配置文件不用到内部去修改
无代码生成 部署之后也不会额外生成代码占用资源 无需编写xml配置文件
迭代快,需要时刻关注变化
封装太深,内部原理复杂 很难精通 因为是对spring的封装
微服务
一种架构风格 一个应用拆分成小型服务 服务围绕业务功能拆分 每个服务运行在自己的进程 可独立部署和升级 不同服务间使用轻量级HTTP交互 去中心化 服务可以使用不同语言不同存储技术
进而产生分布式:springboot+springcloud
远程调用:服务间需要调用 服务发现:服务部署在不同机器,需要看机器上的服务是否可用 负载均衡:选择哪台机器运行服务 配置管理:配置中心 服务监控: 链路追踪:a调b调c 若出问题可追踪 日志管理: 任务调度:
云原生:cloud native 原生应用如何上云
2021-08-02 19:48:47.852 INFO 13672 --- [ main] boot.mainapp1 : No active profile set, falling back to default profiles: default
2021-08-02 19:48:47.940 WARN 13672 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [E:\learnspringboot2\target\classes\boot\controller\Hellohandle.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\learnspringboot2\target\classes\boot\controller\Hellohandle.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 60
2021-08-02 19:48:47.955 ERROR 13672 --- [ main] o.s.boot.SpringApplication : Application run failed``
springboot版本问题
@EnableConfiguration通过@import帮我们自动导入了127个自动配置类 但不是全部生效 是利用@conditional来判断条件看是否生效,默认会绑定配置文件指定的值xxxProperties和配置文件绑定生效的配置类会给容器装配一些组件 功能就生效了 如果用户有自己配置 就以用户配置的优先 用户想修改默认配置 就去application配置文件改
debug=true 控制台可打印未生效的