springspring-bootgmavenplus

Name for argument of type [java.lang.String] not specified. Ensure that the compiler uses the '-parameters' flag


We upgraded to Spring Boot 3.2.2 which uses Spring Framework 6.0.2 and know that they removed a class that would use byte code to determine parameter names to @PathVariables and @RequestParams, I tried to find all of them and type in the names of the parameters in all our Controllers, and I got them all, but still getting this error somewhere. We are using Groovy, so our maven plugin is the Groovy plugin, to the Java plugin, so the solutions given in the Spring documentation does not cover the groovy plugin. But I have also tried to add the -parameters configuration into the Groovy plugin with

       <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.13.1</version>
            <configuration>
                <parameters>true</parameters>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>addSources</goal>
                        <goal>addTestSources</goal>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>compileTests</goal>
                        <goal>removeStubs</goal>
                        <goal>removeTestStubs</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

but we are still getting these errors.

How do we fix this?


Solution

  • Here is our solution.

    1. Even if you are using the GMavenPlus plugin to generate Java stubs and compile, you also have to add the Maven Compiler Plugin

       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>3.12.1</version>
           <configuration>
               <compilerArgs>
                   <arg>-parameters</arg>
               </compilerArgs>
           </configuration>
       </plugin>
      
    1. Then you have to run man clean install so that anything already built, will be rebuilt with using the -parameters argument to the Java compiler.