Ana*_*nas 5 java datasource jar intellij-idea spring-boot
正如问题标题中提到的,我面临问题Cannot determine embedded database driver class for database type NONE
。我构建的应用程序是在 spring boot 上构建的,当我在 intellij 中运行代码时工作正常。
我关注了有关同一异常的几个问题,他们建议我需要spring.datasource
在 application.properties 文件中添加属性。我已经有了它们,但仍然面临同样的问题。当我使用 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
Run Code Online (Sandbox Code Playgroud)
运行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).
小智 3
您应该从 Maven 创建 jar,为此,请转到顶部的“查看” ,然后转到“工具 Windows/Maven 项目”,然后双击“在Maven 的LifeCycle选项中安装”。使用该命令创建的 jar 而不是使用 intellij。它应该有效。
归档时间: |
|
查看次数: |
14144 次 |
最近记录: |