SpringBoot-启动报错(Error starting ApplicationContext)

搭建SpringBoot+mybatis+maven集成项目,在运行启动类main函数的时候控制台报出如下错误,启动失败:


 
   
   
   
   
  1. Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
  2. 2018- 07- 18 16: 57: 29.514 ERROR 17300 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
  3. ***************************
  4. APPLICATION FAILED TO START
  5. ***************************
  6. Description:
  7. Cannot determine embedded database driver class for database type NONE
  8. Action:
  9. 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. "1.0" encoding= "UTF-8"?>
  2. "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. 4.0.0
  5. SpringBoot
  6. SpringBoot
  7. 0.0.1-SNAPSHOT
  8. war
  9. SpringBoot Maven Webapp
  10. http: //maven.apache.org
  11. UTF- 8
  12. 1.7
  13. 1.7
  14. org.springframework.boot
  15. spring-boot-starter-parent
  16. 1.5.8.RELEASE
  17. src/main/java
  18. ** /*.properties
  19. **/*.xml
  20. false
  21. src/main/resources
  22. ** /*.properties
  23. **/*.xml
  24. false
  25. org.springframework.boot
  26. spring-boot-starter
  27. org.mybatis.spring.boot
  28. mybatis-spring-boot-starter
  29. 1.3.1
  30. org.springframework.boot
  31. spring-boot-devtools
  32. true
  33. org.springframework.boot
  34. spring-boot-starter-web
  35. org.springframework.boot
  36. spring-boot-starter-test
  37. test
  38. org.springframework.boot
  39. spring-boot-starter-jdbc
  40. org.springframework.boot
  41. spring-boot-starter-tomcat
  42. provided
  43. log4j-over-slf4j
  44. org.slf4j
  45. org.springframework.boot
  46. spring-boot-starter-tomcat
  47. mysql
  48. mysql-connector-java
  49. 5.1.42
  50. SpringBoot
  51. org.springframework.boot
  52. spring-boot-maven-plugin
  53. true
  54. maven-clean-plugin
  55. 3.0.0
  56. maven-resources-plugin
  57. 3.0.2
  58. maven-compiler-plugin
  59. 3.7.0
  60. maven-surefire-plugin
  61. 2.20.1
  62. maven-war-plugin
  63. 3.2.0
  64. maven-install-plugin
  65. 2.5.2
  66. maven-deploy-plugin
  67. 2.8.2
  68. org.eclipse.m2e
  69. lifecycle-mapping
  70. 1.0.0
  71. org.apache.maven.plugins
  72. maven-resources-plugin
  73. [3.0.2,)
  74. resources

项目完整路径:

很奇怪,我将配置文件全部放在resources文件夹下,官方文档也建议将配置文件放在此文件夹下,但是就是找不到我的数据库配置文件,具体原因暂时还不明白。

解决方法:将数据库配置文件(我的是上图resources文件夹下的application.properties)复制到src/java/main目录下,复制后路径如下图所示:

其中resources目录下的application.properties文件可以删除了。

上述操作后成功启动项目,问题解决。

发布了12 篇原创文章 · 获赞 15 · 访问量 5万+

你可能感兴趣的:(SpringBoot,Java,java,spring,boot)