【问题标题】:JHipster 6.0.1: Liquibase tasks failJHipster 6.0.1:Liquibase 任务失败
【发布时间】:2019-05-15 23:53:48
【问题描述】:

按照示例博客应用程序 (http://gist.asciidoctor.org/?github-mraible/jhipster5-demo//README.adoc) 试用 JHipster v6.0.1。选择 Gradle 作为构建工具,在开发和生产中使用 MariaDB,liquibase 任务失败。

  • 安装开发环境:

    • 安装 MariaDB 10.3
    • 安装 JDK 11 并相应设置环境变量/路径
    • 安装节点 (10.15.3) => npm v6.4.1
    • 安装 yarn (1.15.2)
    • 启动 shell,然后在命令行:
      • 安装约曼:npm install -g yo
      • 安装JHipster:npm install -g generator-jhipster
  • 创建一个新目录,blog,cd 进入并输入:jhipster

  • 选择与上面链接的教程中几乎相同的选项,在开发和生产中都使用 MariaDB,并使用 Gradle 作为构建工具。
  • 启动服务器:./gradlew
  • 运行:yarn start

一切都很好。数据库表按预期创建和填充,Web 应用程序运行良好。

现在,当我停止服务器并尝试运行任何 liquibase 任务时,我得到了同样的错误。例如,在命令行上运行:./gradlew liquibaseClearChecksums 会导致:

> Task :liquibaseClearChecksums FAILED

During the build, one or more dependencies that were declared without a version failed to resolve:
    org.mariadb.jdbc:mariadb-java-client:

Did you forget to apply the io.spring.dependency-management plugin to the blog project?


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':liquibaseClearChecksums'.
> Could not resolve all files for configuration ':liquibaseRuntime'.
   > Could not find org.mariadb.jdbc:mariadb-java-client:.
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

堆栈跟踪提供了更多信息:

Could not resolve all files for configuration ':liquibaseRuntime'.
> Could not find org.mariadb.jdbc:mariadb-java-client:.
  Required by:
      project :

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':liquibaseClearChecksums'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':liquibaseRuntime'.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: 
Could not find org.mariadb.jdbc:mariadb-java-client:.
Required by:
    project :

我在 Windows 10 和 Linux openSUSE 15 上得到了相同的结果。但是,当使用 Maven 时,liquibase 任务可以正常工作。这只是我吗?有人知道为什么吗?

[JHipster:6.0.1; JDK11; MariaDB 10.3.14;节点 v10.15.3;纱线 v1.15.2; npm v6.9.0; Gradle v5.4.1]

PS:删除 JHipster 6.0.1,然后安装 v5.8.2 (npm install -g generator-jhipster@5.8.2),重复上述过程,Gradle liquibase 任务正常工作!我认为这是新 JHipster 6.0.1 部署的一个错误......我应该/如何向开发团队报告这个问题?有什么临时修复的想法吗?

此外,还花时间比较了两个版本(5.8.2 和 6.0.1)中的 build.gradle 文件;它们完全不同,除了:5.8.2 版本直接引用了io.spring.dependency-management 插件,我没有什么明显的错误,但 6.0.1 版本没有...

【问题讨论】:

    标签: gradle mariadb jhipster liquibase


    【解决方案1】:

    好的!我有一个解决方案...

    我在build.gradle 文件中添加了以下+ 行(从第28 行开始):

        id "org.sonarqube" version "2.7"
    +   id "io.spring.dependency-management" version "1.0.7.RELEASE"
        //jhipster-needle-gradle-plugins - JHipster will add additional gradle plugins here
      }
    
      sourceCompatibility=1.8
      targetCompatibility=1.8
      assert System.properties["java.specification.version"] == "1.8" || "11" || "12"
    
      apply plugin: "org.springframework.boot"
    + apply plugin: "io.spring.dependency-management"
      apply plugin: "propdeps"
    

    我选择了io.spring.dependency-management 1.0.7 版,因为the Gradle plugin page 引用它作为最新版本(在撰写本文时)。

    我现在可以运行 ./gradlew liquibaseClearChecksums 并获得成功。

    但运行 ./gradlew liquibaseDiffChangeLog 失败。开启stacktrace,出现如下错误:

    :liquibaseDiffChangeLog FAILED
    liquibase-plugin: Running the 'main' activity...
    Starting Liquibase at Tue, 21 May 2019 07:16:59 PDT (version 3.6.3 built at 2019-01-29 11:34:48)
    Unexpected error running Liquibase: The option --referenceUrl is required.
    liquibase.exception.CommandLineParsingException: The option --referenceUrl is required.
        at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1419)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1026)
        at liquibase.integration.commandline.Main.run(Main.java:199)
        at liquibase.integration.commandline.Main.main(Main.java:137)
    

    为了解决这个问题,我将liquibase/activities/diffLogreferenceUrl 参数复制/粘贴到liquibase/activities/main 部分(参见下面的+ 行):

    liquibase {
      activities {
        main {
          driver "org.mariadb.jdbc.Driver"
          url "jdbc:mariadb://localhost:3306/blog"
          username "<username>"
          password "<password>"
          changeLogFile "src/main/resources/config/liquibase/master.xml"
          defaultSchemaName ""
          logLevel "debug"
          classpath "src/main/resources/"
    +     referenceUrl "hibernate:spring:org.jhipster.blog.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy"
        }
    

    我现在可以运行 ./gradlew liquibaseDiffChangeLog 并获得成功。通过这些更改,我成功地在 Linux 和 Windows 10 上测试了 liquibase 任务。

    我是唯一注意到这一点的人吗? JHipster 团队没有注意到这一点吗?没有测试 JHipster/Gradle/liquibase 配置吗?我的修复是一个完整的解决方案吗?

    对 JHipster/Gradle/liquibase 配置有经验的人能否提供一些见解/确认...?

    【讨论】:

    • 刚刚跟进:新版JHipster(6.1.0)依然存在这个问题!
    • 新版JHipster (6.1.1) 仍然存在这个问题! JHipster/Gradle/MariaDB/liquibase 任务是否在 JHipster 中不受支持/测试?我是唯一注意到这一点的人吗? PS:上述更改仍然有效,并且使用最新版本的 io.spring.dependency-management (1.0.8.RELEASE) @PascalGrimaud
    • JHipster 6.1.2 仍然存在这个问题。 @pascal-grimaud
    • 您可能想在适当的 git-repo github.com/jhipster 中提出问题,而不是在此处发表评论
    • 好的!一个有趣的发展...我刚刚测试了新的 v6.4.1 版本,liquibaseClearChecksums 似乎“开箱即用”(即您不需要添加对 @987654341 的任何引用@), 但是 liquibaseDiffChangeLog 仍然需要您将liquibase/activities/diffLog referenceUrl 参数复制/粘贴到liquibase/activities/main部分。
    【解决方案2】:

    我遇到了同样的问题并禁用了“cacheProvider no”缓存。 当您运行应用程序时,二级缓存还有另一个问题,我认为这是因为 DB 驱动程序。 希望能帮到你!

    【讨论】:

    • 马可!感谢您的回复/建议。我再次重复了整个项目,这一次当被问到:“你想使用 Spring 缓存抽象吗?”时,我回答“否”(从而禁用了二级缓存)。在完全构建/运行(没有问题)之后,liquibase 任务仍然失败,原因与我的帖子中提到的相同,在所有平台上。 (关于数据库驱动程序的好主意,但在我的情况下,我无法想象当一切都与 Maven 一起工作时,数据库驱动程序会如何影响事情。我怀疑 Gradle 配置中缺少某些东西......)
    猜你喜欢
    • 1970-01-01
    • 2015-12-28
    • 2017-01-15
    • 2016-12-29
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多