2017-05-24 76 views
-4

我得到以下異常:「應用程序未能啓動」

2017-05-24 09:41:40.779 INFO 4412 --- [   main] com.develop.NewApplication    : Starting NewApplication on DESKTOP-4GP5JJA with PID 4412 (started by Athira S in C:\Users\Athira S\workspace\new) 
2017-05-24 09:41:40.779 INFO 4412 --- [   main] com.develop.NewApplication    : No active profile set, falling back to default profiles: default 
2017-05-24 09:41:40.857 INFO 4412 --- [   main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]6a28ffa4: startup date [Wed May 24 09:41:40 EDT 2017]; root of context hierarchy 
2017-05-24 09:41:41.886 INFO 4412 --- [   main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 
2017-05-24 09:41:42.198 WARN 4412 --- [   main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is 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). 
2017-05-24 09:41:42.214 INFO 4412 --- [   main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 
2017-05-24 09:41:42.214 ERROR 4412 --- [   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). 
+0

請不要編輯您的問題,使其無效現有的答案。相反,創建一個新問題。 – Matt

回答

0

我無法找到你的問題。對於這個錯誤,你應該在你的pom中加入一些嵌入的jdbc驅動jar,比如H2,sqlite。對於H2,它是:

<dependency> 
    <groupId>com.h2database</groupId> 
    <artifactId>h2</artifactId> 
</dependency> 

如果您使用spring-boot-starter-parent作爲父項,則不需要版本。

0

假設你正在處理一個春天啓動的應用程序,你有2個解決方案:

選項1.如果你有,你可以連接到您的應用程序的數據庫,設置屬性組春天數據源:

樣品application.properties:

spring.datasource.url=jdbc://mysql://localhost:3306/dbname 
spring.datasource.username=db_username 
spring.datasource.password=db_password 

(同樣的屬性組可在YML如果使用的是被設置:)

樣品application.yml:

spring: 
    datasource: 
    url: jdbc:mysql://localhost:3306/dbname 
    username: db_username 
    password: db_password 

OPTION 2.如果沒有有一個數據庫連接到

拆下彈簧引導啓動-JDBC [依賴或spring-boot-starter-jpa作爲jdbc啓動器是啓動器jpa的依賴關係]

如果您使用的是maven,則該依賴關係如下所示:

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-jdbc</artifactId> 
</dependency> 

在gradle這個,它會是這樣的:

compile 'org.springframework.boot:spring-boot-starter-jdbc'

如果這是不適合你的話,請添加一些更多的內容(比如你的pom.xml | build.gradle和/或application.properties | application.yml,以便我們可以看到更多的事情。