Recently, a project was developed with idea + maven, and it has been running without problem. Because idea takes up too much memory, I want to debug a problem on eclipse. I found the following errors when I start Eclipse:
Caused by: java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
at feign.Util.checkState(Util.java:129)
at org.springframework.cloud.openfeign.annotation.PathVariableParameterProcessor.processArgument(PathVariableParameterProcessor.java:51)
at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:299)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:111)
at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:194)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:62)
Obviously, it is because the feignclient Parameter annotation does not display the specified value. The source code is as follows:
@GetMapping("projects/{projectId}/models")
Result<RSCPage<Model>> list(@PathVariable String projectId, @RequestParam Integer current,
@RequestParam Integer pageSize, @RequestParam(required = false) String name,
@RequestParam(required = false) Integer relationship, @RequestParam(required = false) String sorter);
There are similar hosts in spring MVC, but no errors are reported.
Generally, it is customary not to specify value when writing spring MVC parameter annotations, such as requestparam/pathvariable. Since the project has been running for some time, code level problems can be eliminated.
According to the spring naming mechanism, if the specified value is not displayed, Both spring MVC and spring faign use the same parameternamediscoverer Defaultparameternamediscoverer To find the parameter name. It attempts to find the parameter name using the following steps:
First, it uses the standardreflectionparameternamediscovery to try to find the variable name with reflection. This is only possible when compiling classes with – parameters. Second, if it fails, use localvariabletableparameternamediscovery. It tries to find the variable name from the debugging information in the ASM library class file. However, the javac compiler ignores the debugging information of parameter names in the java interface class file. The difference between spring MVC and faign appears here. Feign is the annotation added on the interface, while spiring MVC is the annotation added on the implementation class. This is why feign cannot find the parameter name without – parameter.
Solution: open the eclipse configuration window window & gt; Preference, expand Java & gt; Compiler, check the option in the red box below and recompile
If you compile manually, you can add the javac parameter – G – parameter parameter
idea and Maven take these parameters by default, so you don’t need to configure them manually
Read More:
- Notes on @ pathvariable annotation in springcloud openfeign
- IntelliJ idea / eclipse automatically generate author annotation signature
- Error in @ param in idea2017.3.4 / * * / annotation
- Solution to the error of @ resource annotation in eclipse spring
- @How to solve eclipse error after setter and @ getter (@ data) annotation
- @Solution to get / set error in eclipse after using data annotation
- An error was reported when idea compiles Java: no symbol was found_ How to solve this problem
- Solution of idea using @ Autowired annotation to report errors
- Idea error: error in method comment @ param parameter
- Eclipse reset annotation shortcuts
- [idea] error occurred when using @ data annotation in Lombok: no related get / set method was found
- The solution of using Autowired annotation to report errors in IntelliJ idea
- Idea ignores compilation errors and runs in eclipse compilation mode
- After eclipse eclipse eclipse imports the correct project, an error is reported in XML and other files
- DB: the solution of table already exist when migrating
- Eclipse: unable to open editor: no ID org.eclipse.jdt . ui.CompilationUnitEditor Editor descriptor for
- Solve the problem of “error empty block statement no empty” in the console (Vue project)
- Mybatis passes in multiple parameters to mapper. And uses @param details to report an error
- Idea stuck and error reported: UI was frozen for xxxxx MS problem solving
- call to member function bind_param() on boolean………..