今天在学习springcloud的时候遇到了一个问题,
ClassNotFoundException: com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect
项目结构如下
springcloud4
--eureka-server
--order-server
--product-server
顶层的pom有
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
我在启动order-server的时候就报了这个异常,其中order-server的启动类代码为
@SpringCloudApplication
@EnableFeignClients
@EntityScan("cn.itcast.order.entity")
public class OrderApplication {
public static void main(String[] args) {
SpringApplication.run(OrderApplication.class, args);
System.out.println("***************************************************");
System.out.println(OrderApplication.class.getSimpleName() + "启动成功");
System.out.println("***************************************************");
}
}
后面我添加了个依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
就可以启动了。
推测是@SpringCloudApplication囊括了很多的springcloud组件在内,但是并没有吧相应的依赖弄进来