unit test meet the exception
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.yunpian.marketing.base.service.client.FlowServiceFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1645)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1178)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:258)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1325)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1291)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)
... 55 more
Caused by: java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
at feign.Util.checkState(Util.java:126)
at org.springframework.cloud.openfeign.annotation.PathVariableParameterProcessor.processArgument(PathVariableParameterProcessor.java:51)
at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:238)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:108)
at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:133)
at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:64)
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:153)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:52)
at feign.Feign$Builder.target(Feign.java:242)
at org.springframework.cloud.openfeign.HystrixTargeter.target(HystrixTargeter.java:39)
at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:223)
at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:252)
at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:232)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:161)
... 66 more
Comment From: spencergibb
Please post your client and versions
Comment From: foxundermoon
@GetMapping("/flow/{id}")
@ResponseBody
Flow findByFlowId(@PathVariable String id);
after add default value ,test success.
@GetMapping("/flow/{id}")
@ResponseBody
Flow findByFlowId(@PathVariable("id") String id);
but the normal run is ok without default value @RequestParam and @PathVariable
Comment From: spencergibb
You have to enable parameter retention in the jdk -parameters or something
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: foxundermoon
I use gradle to run test task . how to pass the -parameters argument, and what the argument means.
Comment From: foxundermoon
why needent add the argument when normal run ?
Comment From: ryanjbaxter
I am not sure what you mean, the build has been passing fine for a while now on multiple CI systems.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: leechor
I also meet exception, and spend some hours to solve it, finally the problem is made by refactor Method class privateGetParameters(), the solvation is compile use javac -parameter ...", if you use idea, add "-parameters" under Java Compiler-> Additonal command line parameters settings. if you use gradle, add
apply plugin: 'java'
compileJava {
options.compilerArgs << '-parameters'
}
`
note that clean your project before try again
Comment From: boly38
equivalent for maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
(doc):
-parameters Stores formal parameter names of constructors and methods in the generated class file so that the method
java.lang.reflect.Executable.getParametersfrom the Reflection API can retrieve them.