imp*_* 7 mysql spring spring-boot
我正在尝试遵循本指南 https://spring.io/guides/gs/accessing-data-mysql/
但本指南是针对 Maven 的,我正在尝试 gradle
并收到此错误
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Run Code Online (Sandbox Code Playgroud)
在 application.properties 中我只有这些东西。
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Run Code Online (Sandbox Code Playgroud)
我尝试了 SO 上所有可能的事情。
我唯一拥有的就是这些
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
Run Code Online (Sandbox Code Playgroud)
或者您必须通过将此行添加到文件来阻止 Spring boot 自动配置数据源application.properties。
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
| 归档时间: |
|
| 查看次数: |
11211 次 |
| 最近记录: |