无法确定嵌入式数据库 driver class 数据库类型 NONE 而 运行 jar
Cannot determine embedded database driver class for database type NONE while running jar
如问题标题中所述,我面临问题 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
运行ning 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).
您应该从 maven 创建 jar,为此转到顶部的 View 然后 Tool Windows/Maven Projects 和从那里双击 Maven 中的 install in LifeCycle 选项。使用该命令创建的 jar 而不是使用 intellij。它
应该可以。
如问题标题中所述,我面临问题 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
运行ning 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).
您应该从 maven 创建 jar,为此转到顶部的 View 然后 Tool Windows/Maven Projects 和从那里双击 Maven 中的 install in LifeCycle 选项。使用该命令创建的 jar 而不是使用 intellij。它 应该可以。