問題 以下:java
2017-07-16 08:50:57.436 INFO 13524 --- [ main] c.p.p.web.PointshopWebApplication : Starting PointshopWebApplication on MSI with PID 13524 (D:\javaProject\com.ppdai.pointshop\pointshop-web\target\classes started by yangliweng in D:\javaProject\com.ppdai.pointshop)web
2017-07-16 08:50:57.436 INFO 13524 --- [ main] c.p.p.web.PointshopWebApplication : No active profile set, falling back to default profiles: defaultredis
2017-07-16 08:50:57.478 INFO 13524 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@179bb86: startup date [Sun Jul 16 08:50:57 GMT+08:00 2017]; root of context hierarchyspring
2017-07-16 08:50:57.798 WARN 13524 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.ppdai.pointshop.web.controller, com.ppdai.pointshop.web]' package. Please check your configuration.apache
2017-07-16 08:50:57.829 INFO 13524 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!tomcat
2017-07-16 08:50:58.001 WARN 13524 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supportedspringboot
2017-07-16 08:50:58.151 WARN 13524 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supportedmybatis
2017-07-16 08:50:58.224 WARN 13524 --- [ main] s.c.a.AnnotationConfigApplicationContext : 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$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. 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).app
2017-07-16 08:50:58.240 INFO 13524 --- [ main] utoConfigurationReportLoggingInitializer : maven
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-07-16 08:50:58.240 ERROR 13524 --- [ main] 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).
Process finished with exit code 1
------------------------我是分割線------------------
網上 找到了所謂的解決 方法:
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class },scanBasePackages = {"com.ppdai.pointshop.web.controller"} ) public class PointshopWebApplication { public static void main(String[] args) { SpringApplication.run(PointshopWebApplication.class, args); } }
可是很 遺憾 ,沒用。
因而 用maven下載 好springboot 的源碼,而後斷點調試 進去 ,看看 是什麼狀況,最後 發現了問題的所在:
由於我這是一個新 項目 ,還 沒有 配置數據源 ,可是我又想在 沒配置數據源的狀況 下去 啓動項目,該怎麼辦呢 ?網上找到的方法是無效的,因而我作了一個大膽的猜想:確定是某個地方加載了這個bean,由於 這是 一個新項目,因此 我以爲 啓動加載的可能性很大,而啓動 加載 只有 POM文件 裏面的依賴才 有可能辦到。下面 是 個人dependency依賴:
<dependencies> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-autoconfigure</artifactId> <version>1.5.4.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot</artifactId> <version>1.5.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> <version>1.5.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>1.5.4.RELEASE</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.5.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>1.5.4.RELEASE</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>1.5.4.RELEASE</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-core --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.3.9.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.3.9.RELEASE</version> </dependency> </dependencies>
一個個排查,最後查到org.mybatis.spring.boot這個依賴 ,註釋掉便可,能夠發現,調試的時候 beannames明顯少了不少。
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.0</version> </dependency>
最終,Spring Boot 啓動成功!