【问题标题】:Spring Boot H2 Version WarningSpring Boot H2 版本警告
【发布时间】:2015-02-14 06:06:12
【问题描述】:

我正在使用带有 H2 数据库的 Spring Boot。在之前的 H2 版本(h2-1.3.173)上,不支持 TO_CHAR 函数。为了解决这个问题,我将我的 H2 版本更新为 (h2-1.4.182),现在可以使用了。

但是,当我运行我的 spring-boot 应用程序时,我收到了这个错误消息“连接断开:”意外状态 16843008”,我环顾四周,根本原因是由于不同的 h2 jdbc 版本。

我检查了我的 spring-boot 参考,它使用了 (h2-1.3.176)。所以,我尝试更新spring-boot的pom.xml。但是有一个警告“覆盖 h2 的托管版本 1.3.176”。是否进行了全新安装,并且成功了。

但是,我有点担心这个警告,任何 spring-boot 专家都可以确认它没有引起任何隐藏问题?

【问题讨论】:

  • 如果您使用 1.4.x 版本,我建议将“;mv_store=false”附加到数据库 URL,因为 1.4 版本中的新存储(MVStore)仍处于测试阶段。

标签: spring-boot h2


【解决方案1】:

Spring Boot 1.1.x 应该可以与 H2 1.4.x 一起正常工作。另外,您可能有兴趣知道最近发布的 Spring Boot 1.2.0 默认使用 H2 1.4.x。

如您所见,警告来自 Maven。假设你使用spring-boot-starter-parent 作为你的 pom 的父级,你继承了com.h2database:h2 的依赖管理。如果您想继续使用 Spring Boot 1.1.x 但没有来自 Maven 的警告,您可以通过覆盖 pom 中的 h2.version 属性来实现:

<properties>
    <h2.version>1.4.182</h2.version>
</properties>

然后声明没有版本的依赖:

<dependencies>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
</dependencies>

【讨论】:

  • 感谢@Andy,我升级到 Spring boot 1.2。
【解决方案2】:

该警告是无害的。它不是直接来自 maven,而是它的 m2e 发出警告,可以通过在 pom.xml 就在版本标记之后添加评论来抑制,如下所示(source):

<dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.200</version><!--$NO-MVN-MAN-VER$--> 
        <scope>runtime</scope>
</dependency>

【讨论】:

    猜你喜欢
    • 2018-06-13
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 2016-08-22
    • 2017-05-19
    • 1970-01-01
    相关资源
    最近更新 更多