未找到处理jdbc:mysql://localhost:3306/的数据库

No database found to handle jdbc:mysql://localhost:3306/

提问人:Bruno 提问时间:11/6/2023 最后编辑:seenukarthiBruno 更新时间:11/6/2023 访问量:70

问:

我在执行命令时遇到问题。我不断遇到似乎与查找数据库有关的问题。mvn flyway:migrate


        <build>
            <plugins>
                <plugin>
                    <groupId>org.flywaydb</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <version>9.22.3</version>
                    <configuration>
                        <url>jdbc:mysql://localhost:3306/fooddeliverydb</url>
                        <user>root</user>
                        <password>password</password>
                    </configuration>
                </plugin>
            </plugins>
        </build>

        <dependencies>
            <!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-maven-plugin -->
            <dependency>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>10.0.0</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.33</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
            <dependency>
                <groupId>com.mysql</groupId>
                <artifactId>mysql-connector-j</artifactId>
                <version>8.2.0</version>
            </dependency>
    
        </dependencies>
    </project>

通过使用flyway插件,我想将SQL脚本迁移到我的数据库上。但是每次尝试修复某些东西时,我都会遇到相同的错误。

"
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  0.623 s
    [INFO] Finished at: 2023-11-05T18:17:11+01:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:9.22.3:migrate (default-cli) on project FoodDelivery: org.flywaydb.core.api.FlywayException: No database found to handle jdbc:mysql://localhost:3306/fooddeliverydb -> [Help 1]
"

MySQL的

mysql

项目结构

Project Struct

Java Maven MySQL-Connector Flyway

评论

1赞 duffymo 11/6/2023
我猜 (1) MySQL 没有在该端口上本地运行,或者 (2) 正在运行的实例尚未设置名为 fooddeliverydb 的数据库。

答:

0赞 DoodleBobBuffPants 11/25/2023 #1

根据你的,你似乎缺少对 的依赖。使用MySQL的文档中有一个Java用法部分,它应该涵盖您需要包含的内容pom.xmlflyway-mysql