如果直接在右上方启动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
最后正常启动