org.springframework.boot.actuate.autoconfigure.metrics.MetricsEndpointAutoConfiguration上的错误处理条件

问题描述 投票:2回答:1

我是Java Spring的新手程序员。我正在将一些测试代码从旧的jHipster项目移至新的项目。我将此添加到pom.xml中以修复编译错误。这解决了我的编译问题,但导致运行时错误。

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
            <version>1.5.7.RELEASE</version>
        </dependency>

我现在遇到这些运行时错误。

Caused by: java.lang.IllegalStateException: Error processing condition on org.springframework.boot.actuate.autoconfigure.metrics.MetricsEndpointAutoConfiguration

Caused by: java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.actuate.metrics.MetricsEndpoint]


 <spring-boot.version>2.2.5.RELEASE</spring-boot.version>

如果我卸下spring-boot-actuator

incompatible types: java.time.Instant cannot be converted to java.util.Date


有人知道如何解决吗?

java spring spring-boot jhipster
1个回答
0
投票

似乎存在依赖性问题。首先,除非您非常确定不会有任何依赖冲突,否则请不要指定版本。这是spring-boot如此流行的原因之一,您无需担心依赖关系及其兼容性。让spring-boot处理。兼容版本将从父级继承。

另一个问题是,为什么要使用spring-boot-actuator?您应该使用spring-boot-starter-actuator

这里是一个小样

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.8.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

然后在dependencies中>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <scope>provided</scope>
        <!-- Spring will find the version compatible with the parent -->
    </dependency>

希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.