新建了一个gradle工程,添加了flyway插件执行flyway task 报错
id 'org.flywaydb.flyway' version '9.1.3'
// gradle 依赖配置 跟随spring走的,版本7.7.3
implementation 'org.flywaydb:flyway-core'
// flyway-mysql
implementation 'org.flywaydb:flyway-mysql:8.5.4'
// 驱动配置
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
runtimeOnly 'mysql:mysql-connector-java'
flyway配置
flyway {
driver = 'com.mysql.jdbc.Driver'
url = 'jdbc:mysql://localhost:3306/jpa?characterEncoding=utf-8'
user = 'super'
password = '123456'
cleanDisabled = false
locations = ['classpath:db/migration/mysql']
}
Caused by: org.flywaydb.core.api.FlywayException: No database found to handle jdbc:mysql://localhost:3306/jpa?characterEncoding=utf-8 at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForUrl(DatabaseTypeRegister.java:54) at org.flywaydb.core.internal.jdbc.DriverDataSource.(DriverDataSource.java:109) at org.flywaydb.core.internal.jdbc.DriverDataSource.(DriverDataSource.java:89) at org.flywaydb.core.api.configuration.ClassicConfiguration.configure(ClassicConfiguration.java:1528) at org.flywaydb.core.api.configuration.FluentConfiguration.configuration(FluentConfiguration.java:943) at org.flywaydb.gradle.task.AbstractFlywayTask.runTask(AbstractFlywayTask.java:610)
框架的代码
public static DatabaseType getDatabaseTypeForUrl(String url) {
List<DatabaseType> typesAcceptingUrl = getDatabaseTypesForUrl(url);
if (typesAcceptingUrl.size() > 0) {
if (typesAcceptingUrl.size() > 1) {
StringBuilder builder = new StringBuilder();
for (DatabaseType type : typesAcceptingUrl) {
if (builder.length() > 0) builder.append(", ");
builder.append(type.getName());
}
LOG.debug("Multiple databases found that handle url '" + redactJdbcUrl(url) + "': " + builder);
}
return typesAcceptingUrl.get(0);
} else {
throw new FlywayException("No database found to handle " + redactJdbcUrl(url));
}
}
private static List<DatabaseType> getDatabaseTypesForUrl(String url) {
if (!hasRegisteredDatabaseTypes) {
registerDatabaseTypes();
}
List<DatabaseType> typesAcceptingUrl = new ArrayList<>();
for (DatabaseType type : registeredDatabaseTypes) {
if (type.handlesJDBCUrl(url)) {
typesAcceptingUrl.add(type);
}
}
return typesAcceptingUrl;
}
@Override
public boolean handlesJDBCUrl(String url) {
if (url.startsWith("jdbc-secretsmanager:mysql:")) {
throw new org.flywaydb.core.internal.license.FlywayTeamsUpgradeRequiredException("jdbc-secretsmanager");
}
return url.startsWith("jdbc:mysql:") || url.startsWith("jdbc:google:") ||
url.startsWith("jdbc:p6spy:mysql:") || url.startsWith("jdbc:p6spy:google:");
}
到这里我就不知道怎么回事了,该配置的都没问题啊。求解答一下
相似问题