aso*_*ana 0 compiler-errors spring-boot
我收到以下异常:
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.springframework.context.annotation.AnnotationConfigApplicationContext@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).
Run Code Online (Sandbox Code Playgroud)
假设您正在处理 Spring Boot 应用程序,您有两种解决方案:
选项 1.如果您有一个可以连接到应用程序的数据库,请为 spring 数据源设置属性组:
示例 application.properties:
spring.datasource.url=jdbc://mysql://localhost:3306/dbname
spring.datasource.username=db_username
spring.datasource.password=db_password
Run Code Online (Sandbox Code Playgroud)
(如果您正在使用,可以在 yml 中设置相同的属性组:)
示例应用程序.yml:
spring:
datasource:
url: jdbc:mysql://localhost:3306/dbname
username: db_username
password: db_password
Run Code Online (Sandbox Code Playgroud)
选项 2. 如果您没有要连接的数据库
删除对 spring-boot-starter-jdbc 的依赖 [或 spring-boot-starter-jpa 因为 jdbc starter 是 starter jpa 的依赖项]
如果您使用的是 maven,则该依赖项如下所示:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在 gradle 中,它会是这样的:
compile 'org.springframework.boot:spring-boot-starter-jdbc'
如果您不是这种情况,请添加更多上下文(例如您的 pom.xml | build.gradle 和/或 application.properties | application.yml,以便我们可以看到更多正在发生的事情。
| 归档时间: |
|
| 查看次数: |
18539 次 |
| 最近记录: |