1、报错如下图:

在这里插入图片描述

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

Description:

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

    Property: spring.datasource.schema[0].class-path
    Value: sql/department.sql
    Origin: class path resource [application.yml]:28:21
    Reason: The elements [spring.datasource.schema[0].class-path,spring.datasource.schema[1].class-path] were left unbound.
    Property: spring.datasource.schema[1].class-path
    Value: sql/employee.sql
    Origin: class path resource [application.yml]:29:21
    Reason: The elements [spring.datasource.schema[0].class-path,spring.datasource.schema[1].class-path] were left unbound.

Action:

Update your application's configuration


Process finished with exit code 1

2、解决方式:

pom.xml文件中的schema配置写错了,如下图中:
在这里插入图片描述

1)去掉class和path中间的中横线;
2)去掉冒号和sql中间的空格;
正确写法如下:

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

3、启动成功后的效果图如下:

在这里插入图片描述

4、启动成功后,数据库表中没有创建表,如下图:

在这里插入图片描述

5、springboot2.0x 执行schema.sql脚本注意要加上一个配置:spring.datasource.initialization-mode=always在这里插入图片描述

6、再次启动spingboot应用,查看数据库,员工和部门表已经生成,如下图:

在这里插入图片描述

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐