zoukankan      html  css  js  c++  java
  • spring beanname 以及 actuator的使用

     spring中给bean默认命名的函数,如上图所示:

    第一:为null或者为空,直接返回;

    第二:如果长度大于1,且第一二个字符串都大写,直接返回;

    第三:其他的,将第一个变成小写的。

    代码验证:

     如图所示3个Bean的命名方式

    @Component
    public class APpleBean1 {
    }
    
    @Component
    public class AppleBean2 {
    }
    
    @Component
    public class APPLEBean3 {
    }
    

     利用 actuator显示bean的name

    http://localhost:8080/actuator/beans

     可以验证上面的结论


    actuator的使用

    	<dependencies>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-actuator</artifactId>
    		</dependency>
    
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-test</artifactId>
    			<scope>test</scope>
    			<exclusions>
    				<exclusion>
    					<groupId>org.junit.vintage</groupId>
    					<artifactId>junit-vintage-engine</artifactId>
    				</exclusion>
    			</exclusions>
    		</dependency>
    	</dependencies>
    
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    			</plugin>
    		</plugins>
    	</build>
    

      

    management:
      endpoints:
        web:
          exposure:
            include: "*"
    

      

    下面是在网上随便找的一个
    链接:https://www.jianshu.com/p/5230be715bd6

    ID描述是否需要鉴权
    actuator 为其他端点提供“发现页面”。要求Spring HATEOAS在classpath路径上。 需要
    auditevents 陈列当前应用程序的审计事件信息。 需要
    autoconfig 展示自动配置信息并且显示所有自动配置候选人以及他们“被不被”应用的原因。 需要
    beans 显示应用程序中所有Spring bean的完整列表。 需要
    configprops 显示所有配置信息。 需要
    dump dump所有线程。 需要
    env 陈列所有的环境变量。 需要
    flyway Shows any Flyway database migrations that have been applied. 需要
    health 显示应用程序运行状况信息 不需要
    info 显示应用信息。 不需要
    loggers 显示和修改应用程序中的loggers配置。 需要
    liquibase 显示已经应用的任何Liquibase数据库迁移。 需要
    metrics 显示当前应用程序的“指标”信息。 需要
    mappings 显示所有@RequestMapping的url整理列表。 需要
    shutdown 关闭应用(默认情况下不启用)。 需要
    trace 显示跟踪信息(默认最后100个HTTP请求)。 需要
  • 相关阅读:
    mysql 历史版本下载
    mysql 5.7 版本 You must reset your password using ALTER USER statement before executing this statement报错处理
    5.7 zip 版本的安装 以及遇到的坑
    mysql 5.6zip版本的卸载与5.7 zip 版本的安装
    mysql数据库的备份与还原
    本地Navicat连接docker里的mysql
    docker修改数据库密码
    docker 在push镜像到本地registry出现的500 Internal Server Error
    linux 没有界面内容显示不全解决办法
    json与map互相转换
  • 原文地址:https://www.cnblogs.com/windy13/p/12088296.html
Copyright © 2011-2022 走看看