我是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
有人知道如何解决吗?
似乎存在依赖性问题。首先,除非您非常确定不会有任何依赖冲突,否则请不要指定版本。这是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>
希望这会有所帮助