簡體   English   中英

運行jar時無法確定數據庫類型為NONE的嵌入式數據庫驅動程序類

[英]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

運行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 on top,然后選擇Tool Windows / Maven Projects ,然后在maven中雙擊LifeCycle選項中的install。 使用該命令創建的jar而不是intellij。 它應該工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM