Error pathvariable annotation was empty on param 0 when migrating idea to eclipse

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: