org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Initialization of bean failed; nested exception is java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1acf9e76 has been closed already
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaInstanceConfigBean' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaInstanceConfigBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inetUtils' defined in class path resource [org/springframework/cloud/commons/util/UtilAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inetUtils' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inetUtilsProperties' defined in class path resource [org/springframework/cloud/commons/util/UtilAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152 has been closed already
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
### The error may exist in Mapper.java (best guess)
### The error may involve Mapper.findAllToE
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
我使用的是一个纯 org.springframework.scheduling.annotation.Scheduled 的任务..但是每次执行都报错..
解决办法:配置文件添加端口号
如:
server:
port: ${SERVER_PORT:9190} #首先取环境变量,如果环境变量中没有,就取 9190 这个固定值
我估计这个错误的原因是:
因为你的代码里没有controller,没有服务端口..springboot 以为不会被外部调用.而释放了资源..