spring-boot: Error : Name for argument of type [java.util.Optional] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
I am using Spring-boot 3.2.1 and getting the above error message which started coming after the upgrade.
I have the below in my Pom But still seeing the error.
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
</plugins>
Any suggestion on what else needs to be added? My spring-boot-parent version is below.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 30 (7 by maintainers)
Commits related to this issue
- fix: 解决https://github.com/spring-projects/spring-boot/issues/39095 — committed to ChenSino/ChenSino by ChenSinoGo 2 years ago
I had same issue in my project. If i used command line the application ran fine but if i used VSCode debug feature the issue was there. I cleaned java language server (command palette > Java: Clean Java Language Server Workspace) and it started to work. Hopefully this helps someone in the future.
Is this basically anywhere we have things like
@RequestParam String id, @PathVariable String otherVariabledoes’t work and it requires that the name is populated@RequestParam("id") String id, @PathVariable("otherVariable") String otherVariable?@williejay2017 with Spring Boot 3.1.5, your application is not compiled with
-parametersbut this works because a fallback is still present. This fallback has been removed in Spring Framework 6.1 and Spring Boot 3.2 upgrades to that version.Even if you’re not getting the error with 3.1.x, you should be getting WARN logs similar to:
None of the solutions above worked on latest STS 4.24.0.RELEASE with gradle project
In this case the solution is just to tick this option at the Java Compiler settings
The solution above (to tick this option at the Java Compiler settings) worked for me, so thanks a bunch!
Estou usando SpringBoot 3.3.1, Java 21 e Intellij Fiz o que o @phfbonini disse e funcionou. pom.xml
@douglasjunior Maybe your tests are not compiled with the parameters flag?
@pwpuser yes, that is correct. For further questions on build configuration please use StackOverflow.
@williejay2017 If you can provide a minimal sample we can have a look. This still very much points to a build configuration problem unfortunately, so not a Spring Boot bug.