"应用程序无法启动"

时间:2017-05-24 04:20:30

标签: spring-boot compiler-errors

我收到以下异常:

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).

3 个答案:

答案 0 :(得分:2)

假设您正在处理Spring启动应用程序,您有两个解决方案:

选项1。如果您有数据库,可以连接到您的应用程序,请设置spring数据源的属性组:

示例application.properties:

OrbitControls

(如果您使用的话,可以在yml中设置相同的属性组:)

示例application.yml:

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

选项2。 如果您有数据库要连接

删除对spring-boot-starter-jdbc [或spring-boot-starter-jpa的依赖关系,因为jdbc starter是starter jpa的依赖项]

如果您使用的是maven,那么依赖性如下所示:

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

在gradle中,它是这样的:

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

如果您不是这种情况,请添加更多上下文(例如您的pom.xml | build.gradle和/或application.properties | application.yml,以便我们可以看到更多内容

答案 1 :(得分:1)

我找不到你的问题。对于这个错误,你应该有一些嵌入式jdbc驱动程序jar,如H2,sqlite,添加到你的pom中。对于H2,它是:

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

如果您使用spring-boot-starter-parent作为父级,则不需要版本。

答案 2 :(得分:0)

我得到这个是因为我的port(8080)在后台使用。杀死那个PID帮了我大忙