Spring 弹簧靴&x2B;HikariCP-自动配置数据源的非确定性故障
在我的本地计算机上,当我从IntelliJ运行一个Spring Boot 2.0.0应用程序时,该应用程序周期性地无法启动,控制台中会显示以下消息: 应用程序无法启动 说明: 无法自动配置数据源:“spring.DataSource.url”未指定,无法自动配置嵌入式数据源 原因:无法确定合适的驱动器类别 当我遇到这个错误时,如果我尝试再次运行应用程序,它(有时)会启动。这种行为似乎是不确定的。有时应用程序在第一次尝试时启动,有时需要连续几次尝试 编辑---------------------------------------------------------------------------- 该错误似乎是由于应用程序无法确定哪个配置文件处于活动状态所致。当应用程序无法启动时,Spring日志记录输出状态为“未设置活动配置文件,返回默认配置文件:默认”。当应用程序成功启动时,日志输出状态为“以下配置文件处于活动状态:本地,permitall”,这是我在application.properties中设置为活动的配置文件 不幸的是,对于我来说,Spring是否决定启动时激活的配置文件是一个掷骰子的过程 ---------------------------------------------------------------------------------- 我的应用程序配置为使用SpringBootStarter数据jpa并连接到Postgres数据库。对于连接池,我使用HIKARIP2.7.8 控制台错误(见下文)表示Hikari无法加载数据源。因为这个错误是不确定的,所以它可能取决于Spring在启动期间创建bean的顺序 spring.datasource.url属性在我的本地应用程序属性文件中定义。应用程序属性文件将spring活动配置文件属性设置为本地 这是我的application.properties文件Spring 弹簧靴&x2B;HikariCP-自动配置数据源的非确定性故障,spring,spring-boot,spring-data-jpa,hikaricp,Spring,Spring Boot,Spring Data Jpa,Hikaricp,在我的本地计算机上,当我从IntelliJ运行一个Spring Boot 2.0.0应用程序时,该应用程序周期性地无法启动,控制台中会显示以下消息: 应用程序无法启动 说明: 无法自动配置数据源:“spring.DataSource.url”未指定,无法自动配置嵌入式数据源 原因:无法确定合适的驱动器类别 当我遇到这个错误时,如果我尝试再次运行应用程序,它(有时)会启动。这种行为似乎是不确定的。有时应用程序在第一次尝试时启动,有时需要连续几次尝试 编辑----------------------
spring.profiles.active=local,permitall
management.endpoints.web.base-path=/
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
这是我的application-local.properties
spring.datasource.url=jdbc:postgresql://localhost/vms?currentSchema=vms
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
我还没有找到失败或成功的模式。如果您有任何关于解决或排除此问题的想法,我们将不胜感激
控制台错误消息
2018-05-18 13:53:49.667错误16228---[ost-startStop-1]o.s.b.web.embedded.tomcat.TomcatStarter:启动tomcat上下文时出错。例外:org.springframework.beans.factory.BeanCreationException。消息:创建在类路径资源中定义了名为“servletEndpointRegistrar”的bean时出错
[org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]:通过工厂方法实例化Bean失败
嵌套异常为org.springframework.beans.beanstantiationException:未能实例化[org.springframework.boot.actuate.endpoint.web.servletendpointregistrator]:工厂方法“servletendpointregistrator”引发异常
嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“healthEndpoint”的bean时出错,该bean在类路径资源[org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]:通过工厂方法实例化bean失败
嵌套异常为org.springframework.beans.beanstantiationException:未能实例化[org.springframework.boot.actuate.health.HealthEndpoint]:工厂方法“HealthEndpoint”引发异常
嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration”的bean时出错:通过构造函数实例化bean失败
嵌套异常为org.springframework.beans.beanstantiationException:未能实例化[org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration$$EnhancerBySpringCGLIB$$61a24aeb]:构造函数引发异常
嵌套异常为org.springframework.beans.factory.BeanCreationException:使用类路径资源[org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]中定义的名称“dataSource”创建bean时出错:通过工厂方法实例化bean失败
嵌套异常为org.springframework.beans.beanInstationException:未能实例化[com.zaxxer.hikari.HikariDataSource]:工厂方法“dataSource”引发异常
嵌套异常为org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:未能确定合适的驱动程序类
如果您使用“spring.datasource.jdbc url”是不确定的,您的意思是“spring.datasource.hikari.jdbc url”吗?我尝试设置此属性,但没有解决问题。我还尝试设置“spring.datasource.hikari.driver类名”,但问题仍然存在。我建议在spring引导问题跟踪程序中报告此问题。建议不错。我将此问题提交给他们的跟踪者: