gpt4 book ai didi

java - 尝试运行 jar 时出现 NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-05 07:34:48 27 4
gpt4 key购买 nike

我的代码编译正常,但是当我尝试运行我的 Jar 时,我在堆栈跟踪中收到以下错误

java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.stream.config.codec.kryo.KryoCodecAutoConfiguration
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.stream.config.ChannelBindingAutoConfiguration] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d]

Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/actuate/endpoint/AbstractEndpoint
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.endpoint.AbstractEndpoint

我也在我的 pom.xml 中添加了执行器作为依赖项。以下是所有依赖项:

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

我错过了什么?会不会是我用的spring boot版本的问题?

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>

我还想了解图片中这个执行器的来源,因为我在这个虚拟项目中只有两个类。

package demo.example.jobIDProcessor;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.integration.annotation.Transformer;
@EnableBinding(Processor.class)
@SpringBootApplication
public class JobIDProcessorApplication {

@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String fetchJD(String jobID) {
return "ye raha JD of "+jobID;
}

public static void main(String[] args) {
SpringApplication.run(JobIDProcessorApplication.class, args);
}
}

及以下内容

package demo.example.jobIDProcessor;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.integration.annotation.Transformer;


@EnableBinding(Processor.class)
public class JobIDProcessorConfig {
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String fetchJD(String jobID) {
return "ye raha JD of "+jobID;
}
}

从哪里调用“org/springframework/boot/actuate/endpoint/AbstractEndpoint”?

最佳答案

这个主要和你使用的cloud stream dependencies版本有关。请尝试在 pom.xml 中添加以下内容

 <dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-dependencies</artifactId>
<version>Fishtown.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

这将指向 cloud-stream-dependencies 的最新版本,它指的是执行器的正确版本

关于java - 尝试运行 jar 时出现 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49925942/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com