我在项目中使用了spring-cloud-starter-sleuth。然后,当它启动时,它将显示ClassNotFoundException:brave.propagation.CurrentTraceContext $ ScopeDecorator
这是一个使用Spring boot 2.1.2RELEASE和Spring cloud Greenwich.RC2的最开始的项目。在添加依赖项“ spring-cloud-starter-sleuth”之前,它运行良好;
我只在其中启动了spring-cloud-starter-sleuth的新项目(spring cloud INITIALIZR演示),但仍然无法正常工作;
POM为:
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.RC2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
代码就是:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
,执行为: 引起原因:java.lang.ClassNotFoundException:brave.propagation.CurrentTraceContext $ ScopeDecorator 在java.net.URLClassLoader.findClass(URLClassLoader.java:382)〜[na:1.8.0_191] 在java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0_191] 在sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:349)〜[na:1.8.0_191] 在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0_191] ...省略了25个共同的框架
答案 0 :(得分:0)
将以下依赖项添加到您的dependencyManagement部分,然后重试!
<ul>
答案 1 :(得分:0)
或者您可以使用Spring Cloud Greenwich.RELEASE
版本来解决ClassNotFoundException问题