我有以下方法春天開機椎融合
@HystrixCommand(commandKey="operator",fallbackMethod="getFakeResponse",commandProperties = {
@HystrixProperty(name = "hystrix.command.operator.execution.isolation.thread.timeoutInMilliseconds", value = "30000")
})
public String getResponse(){
try {
Thread.sleep(6000000l);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}
return "the real thing";
}
當過我嘗試運行我的單元測試代碼來測試它,我得到以下異常
然而com.netflix.hystrix。 contrib.javanica.exception.HystrixPropertyException:無法設置Command屬性。 groupKey:'HystrixComponentPOC',commandKey:'operator',threadPoolKey:'' at com.netflix.hystrix.contrib.javanica.command.GenericSetterBuilder.build(GenericSetterBuilder.java:88) at com.netflix.hystrix.contrib。 javanica.command.AbstractHystrixCommand。(AbstractHystrixCommand.java:52) 在com.netflix.hystrix.contrib.javanica.command.GenericCommand。(GenericCommand.java:35) 在com.netflix.hystrix.contrib.javanica.command。 HystrixCommandFactory.create(HystrixCommandFactory.java:44) 在com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.methodsAnnotatedWithHystrixCommand(HystrixCommandAspect.java:85) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(未知來源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知來源) 在java.lang.reflect.Method.invoke(未知來源) 在org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) 在org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) 在org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) 在org.springframework.aop.framework.ReflectiveMethodInvocation。繼續進行(ReflectiveMethodInvocation.java:168) 在org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) 在org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java :179) 在org.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) 在com.masary.topup.HystrixComponentPOC $$ EnhancerBySpringCGLIB $$ 95f9b3dd.getResponse() 在com.masary。 topup.refactor.LedgerUpdateTestCases.test(LedgerUpdateTestCases.java:50) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(來源不明) 在sun.reflect.DelegatingMethodAccessorImpl.invoke( (Unknown Source) at org.junit.internal.runners.model .ReflectiveCallable.run(ReflectiveCallable.ja在org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 處, junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test。 context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner。 runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4C lassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner $ 3。運行(ParentRunner.java:290) at org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit .runners.ParentRunner.access $ 000(ParentRunner.java:58) at org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate (RunBeforeTestClassCallbacks.java:61) 在org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) 在org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 的組織。 eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 引起:java。 lang.IllegalArgumentException:未知的命令屬性:hystrix.command.operator.execution.isolation.thread.timeoutInMilliseconds at com.netflix.hystrix.contrib.javanica.conf.HystrixPropertiesMa nager.initializeProperties(HystrixPropertiesManager.java:125) at com.netflix.hystrix.contrib.javanica.conf.HystrixPropertiesManager.initializeCommandProperties(HystrixPropertiesManager.java:99) at com.netflix.hystrix.contrib.javanica.command.GenericSetterBuilder。建(GenericSetterBuilder.java:86) ...... 47多個
,我可以用除外行爲成功運行它,當我刪除註釋,並添加
hystrix.command.operator.execution .isolation.thread.timeoutInMilliseconds = 30000
我的屬性文件
由唯一的配置我是@EnableHystrix我的主類的方式,我用的彈簧引導1.4.0.RELEASE
任何幫助嗎?
非常感謝,現在工作正常 –