复制代码

为懒人提供无限可能,生命不息,code不止

人类感性的情绪,让我们知难行难
我思故我在
日拱一卒,功不唐捐
  • 首页
  • 前端
  • 后台
  • 数据库
  • 运维
  • 资源下载
  • 实用工具
  • 接口文档工具
  • 登录
  • 注册

springboot

【原创】spring.datasource.url' is not specified and no embedded datasource could be auto-configured

作者: whooyun发表于: 2018-03-28 10:53

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

2018-03-28 10:33:11.574  INFO 1140336 --- [           main] com.qie.QietripApplication               : Starting QietripApplication on PC-20170608ICJP with PID 1140336 (E:\qietrip\target\classes started by Administrator in E:\qietrip)
2018-03-28 10:33:11.577  INFO 1140336 --- [           main] com.qie.QietripApplication               : No active profile set, falling back to default profiles: default
2018-03-28 10:33:11.689  INFO 1140336 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3c153a1: startup date [Wed Mar 28 10:33:11 CST 2018]; root of context hierarchy
2018-03-28 10:33:12.470  WARN 1140336 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.qie]' package. Please check your configuration.
2018-03-28 10:33:13.634  INFO 1140336 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-03-28 10:33:13.664  INFO 1140336 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-03-28 10:33:13.664  INFO 1140336 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
2018-03-28 10:33:13.678  INFO 1140336 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\Program Files\Java\jdk1.8.0_31\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\Program Files\Java\jdk1.8.0_31\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;%M2_HOME%/bin;D:\Program Files\TortoiseSVN\bin;D:\Program Files\SlikSvn\bin;E:\casperjs-1.1.4\bin;E:\phantomjs\bin;D:\Program Files\TortoiseGit\bin;d:\Program Files\Git\cmd;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;.]
2018-03-28 10:33:13.824  INFO 1140336 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-03-28 10:33:13.824  INFO 1140336 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2139 ms
2018-03-28 10:33:14.007  INFO 1140336 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-03-28 10:33:14.011  INFO 1140336 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-28 10:33:14.011  INFO 1140336 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-03-28 10:33:14.012  INFO 1140336 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-03-28 10:33:14.012  INFO 1140336 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-03-28 10:33:14.297  WARN 1140336 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2018-03-28 10:33:14.300  INFO 1140336 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-03-28 10:33:14.389  INFO 1140336 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-03-28 10:33:14.391 ERROR 1140336 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

看其中的关键点
auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured. 很明显是启用springboot的自动配置,但是又没找到properties中spring.datasource.url属性导致的。

解决方法

1、排除数据源的自动化配置就可以了

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})