尝试运行jar时出现NoClassDefFoundError

时间:2018-04-19 16:26:27

标签: java spring spring-boot spring-boot-actuator spring-cloud-dataflow

我的代码编译得很好但是当我尝试运行我的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>

我错过了什么?可以是因为我正在使用的春季启动版本吗?

<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;
    }
}

这是&#34; org / springframework / boot / actuate / endpoint / AbstractEndpoint&#34;被召唤?

1 个答案:

答案 0 :(得分:0)

这主要与您使用的云流依赖关系版本有关。请尝试在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,它引用了正确的执行器版本