我正在努力学习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
这首先解决了问题,但有人说这不是一个适当的解决办法。所以我有两个问题:
谢谢。
发布于 2022-01-21 14:21:27
您似乎错误地拼写了属性spring.datasoruce.url。数据源的拼写不正确。你能试试spring.datasource.url吗?
https://stackoverflow.com/questions/70802700
复制相似问题