spring beanname 以及 actuator的使用

时间:2019-12-23
本文章向大家介绍spring beanname 以及 actuator的使用,主要包括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请求)。 需要

原文地址:https://www.cnblogs.com/windy13/p/12088296.html