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. <?xml version= "1.0" encoding= "UTF-8"?>
  2. <project xmlns= "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. <modelVersion> 4.0.0</modelVersion>
  5. <groupId>SpringBoot</groupId>
  6. <artifactId>SpringBoot</artifactId>
  7. <version> 0.0.1-SNAPSHOT</version>
  8. <packaging>war</packaging>
  9. <name>SpringBoot Maven Webapp</name>
  10. <url>http: //maven.apache.org</url>
  11. <properties>
  12. <project.build.sourceEncoding>UTF- 8</project.build.sourceEncoding>
  13. <maven.compiler.source> 1.7</maven.compiler.source>
  14. <maven.compiler.target> 1.7</maven.compiler.target>
  15. </properties>
  16. <parent>
  17. <groupId>org.springframework.boot</groupId>
  18. <artifactId>spring-boot-starter-parent</artifactId>
  19. <version> 1.5.8.RELEASE</version>
  20. <relativePath></relativePath>
  21. </parent>
  22. <resources>
  23. <resource>
  24. <directory>src/main/java</directory>
  25. <includes>
  26. <include>** /*.properties</include>
  27. <include>**/*.xml</include>
  28. </includes>
  29. <filtering> false</filtering>
  30. </resource>
  31. <resource>
  32. <directory>src/main/resources</directory>
  33. <includes>
  34. <include>** /*.properties</include>
  35. <include>**/*.xml</include>
  36. </includes>
  37. <filtering> false</filtering>
  38. </resource>
  39. </resources>
  40. <dependencies>
  41. <dependency>
  42. <groupId>org.springframework.boot</groupId>
  43. <artifactId>spring-boot-starter</artifactId>
  44. </dependency>
  45. <dependency>
  46. <groupId>org.mybatis.spring.boot</groupId>
  47. <artifactId>mybatis-spring-boot-starter</artifactId>
  48. <version> 1.3.1</version>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.springframework.boot</groupId>
  52. <artifactId>spring-boot-devtools</artifactId>
  53. <optional> true</optional>
  54. </dependency>
  55. <dependency>
  56. <groupId>org.springframework.boot</groupId>
  57. <artifactId>spring-boot-starter-web</artifactId>
  58. </dependency>
  59. <dependency>
  60. <groupId>org.springframework.boot</groupId>
  61. <artifactId>spring-boot-starter-test</artifactId>
  62. <scope>test</scope>
  63. </dependency>
  64. <dependency>
  65. <groupId>org.springframework.boot</groupId>
  66. <artifactId>spring-boot-starter-jdbc</artifactId>
  67. </dependency>
  68. <dependency>
  69. <groupId>org.springframework.boot</groupId>
  70. <artifactId>spring-boot-starter-tomcat</artifactId>
  71. <scope>provided</scope>
  72. </dependency>
  73. <exclusions>
  74. <exclusion>
  75. <artifactId>log4j-over-slf4j</artifactId>
  76. <groupId>org.slf4j</groupId>
  77. </exclusion>
  78. <exclusion>
  79. <groupId>org.springframework.boot</groupId>
  80. <artifactId>spring-boot-starter-tomcat</artifactId>
  81. </exclusion>
  82. </exclusions>
  83. <!-- mysql连接 -->
  84. <dependency>
  85. <groupId>mysql</groupId>
  86. <artifactId>mysql-connector-java</artifactId>
  87. <version> 5.1.42</version>
  88. </dependency>
  89. <!-- mybatis -->
  90. </dependencies>
  91. <build>
  92. <finalName>SpringBoot</finalName>
  93. <pluginManagement><!-- lock down plugins versions to avoid using Maven
  94. defaults (may be moved to parent pom) -->
  95. <plugins>
  96. <plugin>
  97. <groupId>org.springframework.boot</groupId>
  98. <artifactId>spring-boot-maven-plugin</artifactId>
  99. <configuration>
  100. <fork>true</fork>
  101. </configuration>
  102. </plugin>
  103. <plugin>
  104. <artifactId>maven-clean-plugin</artifactId>
  105. <version>3.0.0</version>
  106. </plugin>
  107. <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
  108. <plugin>
  109. <artifactId>maven-resources-plugin</artifactId>
  110. <version>3.0.2</version>
  111. </plugin>
  112. <plugin>
  113. <artifactId>maven-compiler-plugin</artifactId>
  114. <version>3.7.0</version>
  115. </plugin>
  116. <plugin>
  117. <artifactId>maven-surefire-plugin</artifactId>
  118. <version>2.20.1</version>
  119. </plugin>
  120. <plugin>
  121. <artifactId>maven-war-plugin</artifactId>
  122. <version>3.2.0</version>
  123. </plugin>
  124. <plugin>
  125. <artifactId>maven-install-plugin</artifactId>
  126. <version>2.5.2</version>
  127. </plugin>
  128. <plugin>
  129. <artifactId>maven-deploy-plugin</artifactId>
  130. <version>2.8.2</version>
  131. </plugin>
  132. <!--This plugin's configuration is used to store Eclipse m2e settings
  133. only. It has no influence on the Maven build itself. -->
  134. <plugin>
  135. <groupId>org.eclipse.m2e</groupId>
  136. <artifactId>lifecycle-mapping</artifactId>
  137. <version>1.0.0</version>
  138. <configuration>
  139. <lifecycleMappingMetadata>
  140. <pluginExecutions>
  141. <pluginExecution>
  142. <pluginExecutionFilter>
  143. <groupId>
  144. org.apache.maven.plugins
  145. </groupId>
  146. <artifactId>
  147. maven-resources-plugin
  148. </artifactId>
  149. <versionRange>[3.0.2,)</versionRange>
  150. <goals>
  151. <goal>resources</goal>
  152. </goals>
  153. </pluginExecutionFilter>
  154. <action>
  155. <ignore></ignore>
  156. </action>
  157. </pluginExecution>
  158. </pluginExecutions>
  159. </lifecycleMappingMetadata>
  160. </configuration>
  161. </plugin>
  162. </plugins>
  163. </pluginManagement>
  164. </build>
  165. </project>

项目完整路径:

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

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

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

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

  •                     <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count">1</span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/weixin_38808487">
                    <img src="https://profile.csdnimg.cn/1/0/E/3_weixin_38808487" class="avatar_pic" username="weixin_38808487">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/2x/3.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/weixin_38808487" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">至尊小宝宝</a></span>
                                            </div>
                    <div class="text"><span>发布了12 篇原创文章</span> · <span>获赞 15</span> · <span>访问量 5万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=weixin_38808487" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值