搭建SpringBoot+mybatis+maven集成项目,在运行启动类main函数的时候控制台报出如下错误,启动失败:
-
Error starting ApplicationContext. To display the auto-configuration report re-run your application with
'debug' enabled.
-
2018-
07-
18
16:
57:
29.514 ERROR
17300 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
-
-
***************************
-
APPLICATION FAILED TO START
-
***************************
-
-
Description:
-
-
Cannot determine embedded database driver
class for database type NONE
-
-
Action:
-
-
If
you
want
an
embedded
database
please
put
a
supported
one
on
the
classpath.
If
you
have
database
settings
to
be
loaded
from
a
particular
profile
you
may
need
to
active
it (
no
profiles
are
currently
active).
报错的原因很明显,是我的项目有需要操作数据库的业务,但是数据库配置文件找不到导致数据类型报NONE值。
我的pom.xml配置:
-
"1.0" encoding=
"UTF-8"?>
-
-
"http://maven.apache.org/POM/4.0.0" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
4.0.0
-
-
SpringBoot
-
SpringBoot
-
0.0.1-SNAPSHOT
-
war
-
SpringBoot Maven Webapp
-
http:
//maven.apache.org
-
-
-
UTF-
8
-
1.7
-
1.7
-
-
-
-
org.springframework.boot
-
spring-boot-starter-parent
-
1.5.8.RELEASE
-
-
-
-
-
-
src/main/java
-
-
**
/*.properties
-
**/ *.xml
-
-
false
-
-
-
src/main/resources
-
-
**
/*.properties
-
**/ *.xml
-
-
false
-
-
-
-
-
-
-
-
-
org.springframework.boot
-
spring-boot-starter
-
-
-
org.mybatis.spring.boot
-
mybatis-spring-boot-starter
-
1.3.1
-
-
-
org.springframework.boot
-
spring-boot-devtools
-
true
-
-
-
org.springframework.boot
-
spring-boot-starter-web
-
-
-
org.springframework.boot
-
spring-boot-starter-test
-
test
-
-
-
org.springframework.boot
-
spring-boot-starter-jdbc
-
-
-
org.springframework.boot
-
spring-boot-starter-tomcat
-
provided
-
-
-
-
log4j-over-slf4j
-
org.slf4j
-
-
-
org.springframework.boot
-
spring-boot-starter-tomcat
-
-
-
-
-
mysql
-
mysql-connector-java
-
5.1.42
-
-
-
-
-
-
SpringBoot
-
-
-
-
org.springframework.boot
-
spring-boot-maven-plugin
-
-
true
-
-
-
-
maven-clean-plugin
-
3.0.0
-
-
-
-
maven-resources-plugin
-
3.0.2
-
-
-
maven-compiler-plugin
-
3.7.0
-
-
-
maven-surefire-plugin
-
2.20.1
-
-
-
maven-war-plugin
-
3.2.0
-
-
-
maven-install-plugin
-
2.5.2
-
-
-
maven-deploy-plugin
-
2.8.2
-
-
-
-
org.eclipse.m2e
-
lifecycle-mapping
-
1.0.0
-
-
-
-
-
-
-
org.apache.maven.plugins
-
-
-
maven-resources-plugin
-
-
[3.0.2,)
-
-
resources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
项目完整路径:
很奇怪,我将配置文件全部放在resources文件夹下,官方文档也建议将配置文件放在此文件夹下,但是就是找不到我的数据库配置文件,具体原因暂时还不明白。
解决方法:将数据库配置文件(我的是上图resources文件夹下的application.properties)复制到src/java/main目录下,复制后路径如下图所示:
其中resources目录下的application.properties文件可以删除了。
上述操作后成功启动项目,问题解决。