首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >gradle 工程之flyway插件报错,貌似是url匹配不正,看了下源码没觉得哪里不对啊?

gradle 工程之flyway插件报错,貌似是url匹配不正,看了下源码没觉得哪里不对啊?

提问于 2022-08-28 16:12:10
回答 1关注 0查看 466

新建了一个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)

框架的代码

代码语言:javascript
复制
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));
    }
}
代码语言:javascript
复制
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;
}
代码语言:javascript
复制
@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:");
}

到这里我就不知道怎么回事了,该配置的都没问题啊。求解答一下

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档