当前位置: 首页 > 工具软件 > Classp > 使用案例 >

Error creating bean with name 'servletEndpointRegistrar' defined in class path resource

公良莫希
2023-12-01

记一次配置内容丢失导致报错问题:Error creating bean with name ‘servletEndpointRegistrar’ defined in class path resource …

  • 报错内容:
 Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: 
	
	
 Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
	
 Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: 
	
	
 Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException:
	
	
	
 Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method 'healthEndpoint' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: 
	
	
 Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration':
 Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: 
	
	
 Failed to instantiate [org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration$$EnhancerBySpringCGLIB$$caa88ea6]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: 
	
 Error creating bean with name 'dataSource': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: 
	
 Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
  • 问题关键在最后一句:
   Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

笔者也是在Error creating bean with name ‘servletEndpointRegistrar’ defined in class path resource
报错纠结许久,降低过spring boot版本,替换报错jar与依赖包,更换maven版本、仓库,事实都是无用

  • 这种问题可能是你的spring.datasource driverClassName等信息没有配置

    	spring.datasource.druid.read.driverClassName = com.mysql.cj.jdbc.Driver
    	spring.datasource.druid.read.url=jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowMultiQueries=true&serverTimezone=GMT%2B8
    	spring.datasource.druid.read.username=root
    	spring.datasource.druid.read.password=123456
    
  • 还可能是你的jdbc依赖问题,是否有添加:

      	<dependency>  
      		<groupId>org.springframework.boot</groupId>  
      		<artifactId>spring-boot-starter-jdbc</artifactId>  
      	</dependency>  
    
 类似资料:

相关阅读

相关文章

相关问答