Sto*_*her 4 java spring spring-boot jhipster
我是一名 Java Spring 新手程序员。我正在将一些测试代码从旧的 jHipster 项目移动到新项目。我将其添加到 pom.xml 中以修复编译错误。这解决了我的编译问题,但导致了运行时错误。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我现在收到这些运行时错误。
引起的原因:java.lang.IllegalStateException:org.springframework.boot.actuate.autoconfigure.metrics.MetricsEndpointAutoConfiguration的处理条件错误引起的:java.lang.IllegalArgumentException:找不到类[org.springframework.boot.actuate.metrics。指标端点]
<spring-boot.version>2.2.5.RELEASE</spring-boot.version>
Run Code Online (Sandbox Code Playgroud)
如果我删除 spring-boot-actuator
不兼容的类型: java.time.Instant 无法转换为 java.util.Date 无法访问 org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter 方法不会覆盖或实现超类型中的方法
有谁知道如何修复?
依赖性似乎有问题。首先,除非您非常确定不会出现任何依赖项冲突,否则不要指定版本。这是如此受欢迎的原因之一spring-boot,您无需担心依赖性及其兼容性。让我们spring-boot来处理吧。兼容版本将从父版本继承。
另一个问题是,为什么使用spring-boot-actuator?你应该使用spring-boot-starter-actuator
这是一个示例 pom
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)
然后在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>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
| 归档时间: |
|
| 查看次数: |
14094 次 |
| 最近记录: |