我正在嘗試學習 Spring 并按照 YouTube 上一個人的指示進行操作。起初,他只初始化了 Spring 專案并撰寫了配置,我復制并創建了名為 employeemanager 的資料庫。簡而言之,我對他做了完全相同的事情,但是當我嘗試運行程式時出現此錯誤:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine suitable jdbc URL
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
我正在使用 MySQL 和 JPA。這是我的配置:
spring.datasoruce.url=jdbc:mysql://localhost:3306/employeemanager
spring.datasource.username=root
spring.datasource.password=2525
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
我在網上找到了一個解決方案,它是這樣寫的:
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 代替 @SpringBootApplication
這首先解決了問題,但是有人提到這不是一個適當的解決方案。所以我有兩個問題:
這個問題的原因是什么,我該如何解決?
我提到的解決方案到底在做什么?
謝謝你。
uj5u.com熱心網友回復:
看來您拼錯了屬性 spring.datasoruce.url 。資料源的拼寫不正確。你可以試試 spring.datasource.url。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/419247.html
標籤:
上一篇:使用SpringIntegrationwithProjectReactor時的主要處理流程編程方法
下一篇:多重分離的Spring屬性系結
