SpringBoot(2)-组件

本文介绍了SpringBoot的重要组件,包括监控信息-actuator、自定义Starter等,并探讨了性能优化方法,如通过VMoptions调整及使用Undertow替代Tomcat提升性能。此外还涉及了多数据源配置及事务一致性实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


前言

SpringBoot组件,actuator
扩展:

概念

1、监控信息-actuator

加入监控依赖包
<dependency>
  	<groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
配置属性
#加载所有端点,默认加载info/health
management.endpoints.web.exposure.include=*

#描述信息
info.blog.url=https://blog.csdn.net/cleancp
info.author=zcp
info.version=@project.version@
启动项目访问:http://localhost:8888/actuator

在这里插入图片描述

  • /actuator/beans
    显示springboot中所有bean的完整列表
    在这里插入图片描述

  • /actuator/configprops
    配置信息
    在这里插入图片描述

  • /actuator/info
    application.properties的配置info信息
    在这里插入图片描述

  • /actuator/health
    健康信息
    在这里插入图片描述

  • /actuator/env
    环境变量信息
    在这里插入图片描述

  • /actuator/mappings
    在这里插入图片描述

2、自定义Starter

@ConditionalOnMissingBean:如果没有bean存在则加载,否则不加载

组件Properties

Autoconfig


3、性能优化

VM options : -Ddebug  
启动项目
============================
CONDITIONS EVALUATION REPORT
============================


Positive matches: 匹配以及匹配的原因
-----------------

Negative matches: 忽略匹配以及忽略的原因
-----------------

Exclusions: 排除的配置类
-----------------

Unconditional classses:没有带任何条件,肯定要扫描的类
-----------------

输出GC信息
-XX:+PrintGCDetails -Xmx32M -Xms5M 输出GC详细信息,设置较小FULLGC频繁  
-Xms1M 设置过小项目不嗯能启动 
Error occurred during initialization of VM
GC triggered before VM initialization completed. Try increasing NewSize, current value 1536K.

在这里插入图片描述

4、tomcat 和 undertow 性能

Apache Jmeter测试性能

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>${spring_boot_version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
    <version>${spring_boot_version}</version>
</dependency>

5、多数据源

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jta-atomikos</artifactId>
    <version>${spring_boot_version}</version>
</dependency>

Atomikos:兼容标准的SUN公司JTA API 、为java平台提供增值服务的并且开源类事务管理器

JTA java事务API,允许应用程序执行分布式事务处理。

多数据源、使事务一致
SqlSessionFactory
SqlSessionTemplate
DataSource
TransactionManage

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值