1. 程式人生 > >解決:Failed to instantiate [com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect]:

解決:Failed to instantiate [com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect]:

在ribbon中使用斷路器hystrix時報如下錯誤:

錯誤描述
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-01-22 17:14:38.196 ERROR 8144 --- [ main] o.s.boot.SpringApplication : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hystrixCommandAspect' defined in class path resource [org/springframework/cloud/netflix/hystrix/HystrixCircuitBreakerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect]: Factory method 'hystrixCommandAspect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/JoinPoint


at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
at com.aikucun.SpringCloudEurekaRibbonApplication.main(SpringCloudEurekaRibbonApplication.java:17) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect]: Factory method 'hystrixCommandAspect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/JoinPoint
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/JoinPoint
at org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration.hystrixCommandAspect(HystrixCircuitBreakerConfiguration.java:60) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration$$EnhancerBySpringCGLIB$$16836522.CGLIB$hystrixCommandAspect$0(<generated>) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration$$EnhancerBySpringCGLIB$$16836522$$FastClassBySpringCGLIB$$9521f8f9.invoke(<generated>) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration$$EnhancerBySpringCGLIB$$16836522.hystrixCommandAspect(<generated>) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.JoinPoint
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_151]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_151]
... 30 common frames omitted

解決方案:

在pom中加入如下依賴,

【注意】一開始使用預設的版本(預設1.8.3)依舊報錯,報錯原因應該是版本衝突

<dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.7.1</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.7.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>


相關推薦

解決Failed to instantiate [com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect]:

在ribbon中使用斷路器hystrix時報如下錯誤: 錯誤描述Error starting ApplicationContext. To display the auto-configuration report re-run your application with

NoClassDefFoundError: com/netflix/hystrix/contrib/javanica/aop/aspectj/HystrixCommandAspect

在Spring Cloud Feign工程中配置斷路器Hystrix的時候,pom.xml檔案已經加入Hystrix相關的jar: <dependency> <groupId>org.spri

【spring cloud】spring cloud 使用feign呼叫,1.fallback熔斷器不起作用,2.啟動報錯Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanica.aop.asp

1.首先使用feign呼叫,需要配置熔斷器 2.配置熔斷器需要將熔斷器注入Bean,被spring可以掃描到 3.熔斷器類需要實現feignClient介面 4.hystrix的jar需要被maven引用,並且在classpath下 5.注意,feignClient上儘量不要使用@RequestMap

解決Failed to execute goal on project aopcore: Could not resolve dependencies for project com.cmos:

maven/Java/web/bootstrap/dataTable/app開發QQ群:566862629。希望更多人一起幫助我學習。 一、問題描述 maven工程  jar包無法下載,報錯如下 :

hibernate報錯解決Unable to instantiate default tuplizer

java 專案啟動報錯 Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

解決Failed to load class "org.slf4j.impl.StaticLoggerBinder".

控制檯輸出 版本 <!-- slf4j --> <dependency> <groupId>org.slf4j</groupId>

Android開發android studio報錯 Failed to resolve: com.android.support.constraint:constraint-layout:1.0.

情景:在build.gradle檔案新增下面程式碼 compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' 點選“Sync now”後報錯: Failed to resolve:co

解決 failed to lazily initialize a collection of role: no session or session was closed問題

出現的異常為:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: cn..domain.User.posts, no session or

解決Failed to resolve: runtime

今天匯入以前同事寫的一個專案,遇到了Failed to resolve: runtime    Open File這個錯誤,懵逼了半天,最後原因在這裡: 在專案的build 檔案中 allproje

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.itcast.j

報錯資訊: Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.

springboot初始化報錯 Failed to instantiate [XXX]: Specified class is an interface

org.springframework.beans.BeanInstantiationException: Failed to

hadoop解決windows下Failed to set permissions of path: mp .staging to 0700

1.0 style ati 配置文件 github unable ica perm lac 17/04/24 15:32:44 WARN util.NativeCodeLoader: Unable to load native-Hadoop library for your

關於出現Failed to instantiate SLF4J LoggerFactory問題原因,解決辦法

下載 depend 1.4 地址 ins 解決辦法 org mir bsp 在創建spring boot 文檔進行配置的時候,因為使用spring boot 父級依賴的版本 <artifactId>spring-boot-starter-parent</a

AndroidStudio解決提示Failed to load AppCompat ActionBar with unknown error

err error studio 項目目錄 them 代碼段 pat androi XML Android Studio 3.1.4 問題:新項目建立時,layout下的xml項目出現Render problem - Failed to load AppCompat Ac

Failed to resolve:com.android.support:appcompat-v7:27.+ 問題的解決方法

新建一個專案,出現 Failed to resolve:com.android.support:appcompat-v7:27.+ 問題: 1 分析 android studio 中的編譯器版本與 build.gradle(app 下)不對應造成的。 開啟 build.

eclipse更新SDK報錯Failed to fetch URL http://dl-ssl.google.com/android/repository/repository-1

Android 開發使用eclipse時,更新sdk報錯:Failed to fetch URL http://dl-ssl.google.com/android/repository/repository-1 原因是由於國內網路訪問谷歌伺服器時“受阻”,所有需要。。。。 解決方法如下: 第一

Failed to resolve: com.android.support:support-annotations:26.0.2的解決方案

在新增依賴的時候,出現如下報錯: 說我缺少了support-annotations:26.0.2的依賴,那麼問題來了,什麼是support-annotations?我的專案裡面用到了嗎? support-annotations註解庫簡介 android-support-anno

解決Connect to xx.xx.xxx.xx :8081 [/xx.xx.xx.xx] failed: Connection refu sed: connect -> [H

1. 自行啟動了個  Nenux 服務。想把本地工程推送到 個人私服,執行命令:mvn deploy 報錯: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (def

Error:Failed to resolve: com.android.support:recyclerview-v7:28.0.0解決方法

在使用Android Studio的過程中需要新增依賴recyclerview,出現報錯: Unable to resolve dependency for ':[e

vmware 安裝報錯failed to install hcmon drivers 完美解決(含VMware15啟用碼)

首先絕大部分使用網上的方法,刪除各種驅動和登錄檔都是結果都是失敗的:再次安裝的結果仍然是: 在網上搜尋幾天找到一位大神部落格,完美解決,試了之後的結果是完美安裝,搬運如下: 解決方法: 第一步: 首先桌面上新建一個文字文件,將下面的程式碼複製進去(因為CSDN部落格複製