SpringBoot官方笔记8其他

文章介绍了如何使用Docker构建SpringBoot应用的容器镜像,包括从依赖到执行器的配置。SpringBootActuator提供了生产就绪的特性,如内置的监控端点,允许通过HTTP进行应用管理和监控。此外,讨论了在Kubernetes环境中的自动检测和部署策略。学习SpringBoot需要理解其基于SpringFramework的自动配置机制。
摘要由CSDN通过智能技术生成

Container Images

FROM eclipse-temurin:17-jre as builder
WORKDIR application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
$ docker build --build-arg JAR_FILE=path/to/myapp.jar .

Production-ready Features

The spring-boot-actuator module provides all of Spring Boot’s production-ready features.

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

Endpoints

Actuator endpoints let you monitor and interact with your application. Spring Boot includes a number of built-in endpoints and lets you add your own. For example, the health endpoint provides basic application health information.

Monitoring and Management Over HTTP

If you are developing a web application, Spring Boot Actuator auto-configures all enabled endpoints to be exposed over HTTP. The default convention is to use the id of the endpoint with a prefix of /actuator as the URL path. For example, health is exposed as /actuator/health.

Loggers

  • TRACE

  • DEBUG

  • INFO

  • WARN

  • ERROR

  • FATAL

  • OFF

  • null

Deploying Spring Boot Applications

You can deploy Spring Boot applications to a variety of cloud platforms, to virtual/real machines, or make them fully executable for Unix systems.

Kubernetes

Spring Boot auto-detects Kubernetes deployment environments by checking the environment for "*_SERVICE_HOST" and "*_SERVICE_PORT" variables. You can override this detection with the spring.main.cloud-platform configuration property.

总结

快速刷完SpringBoot官方网站,刚开始还比较能看懂,越到后面越发现,整个内容偏向于“配置”说明,能吸收和理解的知识很少,从我做的笔记也是能看出来这点。

这跟SpringBoot本身的设计也是一致的,即SpringBoot是在Spring Framework基础之上做的“自动配置”,从繁杂的xml配置中解脱出来,SpringBoot本身就是一个外壳。

学习SpirngBoot,需要对它的内核进行学习,也就是Spring Framework,还好也有官方文档,虽然有点难找:

https://docs.spring.io/spring-framework/reference/overview.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值