运行jar时无法确定数据库类型为NONE的嵌入式数据库驱动程序类

时间:2017-07-28 11:02:56

标签: java spring-boot intellij-idea jar datasource

如问题标题中所述,我面临问题Cannot determine embedded database driver class for database type NONE。我构建的应用程序是在Spring启动时工作正常,当我运行intellij中的代码时。

我已经关注了同一个异常的几个问题,他们建议我需要在application.properties文件中添加spring.datasource属性。我已经拥有它们并仍然面临同样的问题。当我使用intellij的工件创建jar文件然后通过以下命令运行它时,会发生此问题。 java - jar myJar.jar

我的application.properties文件

# ===============================
# = DATA SOURCE
# ===============================
spring.datasource.url = jdbc:mysql://localhost:3306/db_wssmith?useSSL=false
spring.datasource.username = 
spring.datasource.password = 
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

运行jar时的错误日志

ERROR org.springframework.boot.SpringApplication - Application startup failed 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).

1 个答案:

答案 0 :(得分:3)

您应该从maven创建jar,为此,请转到查看,然后工具Windows / Maven项目,然后双击中的安装maven中的LifeCycle 选项。使用该命令创建的jar而不是intellij。它 应该工作。