nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind p

如果直接在右上方启动SpringBoot并没有使用tomcat容器,项目启动后就直接关闭了
出现如下:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-22 21:24:43.114 ERROR 6904 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@6754ef00 type = java.util.List<java.lang.String>, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: spring.datasource.schema[0].classpath
    Value: sql/department.sql
    Origin: class path resource [application.yml]:25:19
    Reason: The elements [spring.datasource.schema[0].classpath,spring.datasource.schema[1].classpath] were left unbound.
    Property: spring.datasource.schema[1].classpath
    Value: sql/employee.sql
    Origin: class path resource [application.yml]:26:19
    Reason: The elements [spring.datasource.schema[0].classpath,spring.datasource.schema[1].classpath] were left unbound.

Action:

Update your application's configuration


Process finished with exit code 1

在SpringBoot的测试类中启动的话
报如下错:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'druid' defined in class path resource [com/atguigu/springbootjdbcmybatis/config/DruidConfig.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.schema' to java.util.List<java.lang.String>

最后解决办法:
删除application.yml文件中的

schema:
     - classpath: sql/department.sql
     - classpath: sql/employee.sql

最后正常启动

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值