Closed jjavery closed 5 months ago
It seems VSCode (at least with the Java extension I've tried) is using Eclipse JDT compiler. You're right, there's not so much documentation around it. I've found how to configure global preferences and the complete reference of the JDT Eclipse compiler options.
I have created a .settings/org.eclipse.jdt.core.prefs
file in my project with the content:
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
It worked for me. Let us know how it goes and if you've found better documentation. I can improve the Spring Framework wiki if this works.
@bclozel thanks for this, I added the file with the line you suggested and I'm no longer seeing IllegalArgumentException when using Run and Debug in VS Code.
Oddly, VS Code (or the JDT Eclipse Complier) is now creating a second file in the .settings
folder: .settings/org.eclipse.buildship.core.prefs
and based on what I'm seeing within this file (paths within the local filesystem) I would advise excluding this second file from source control (add to .gitignore).
With regard to the Spring Framework Wiki:
./gradlew bootRun
.spring-graphql
come up in other Spring projects? My teammates use both IntelliJ and VS Code. I'd like to be able to point them to documentation describing how to configure their projects and IDEs so they can continue to run/debug our Spring-based projects without this problem. The Spring Framework 6.1 upgrade guidance isn't the first place we'd think to look for this, and especially won't be in the future when new Spring Framework versions are released. Is there a wiki page that describes how to work with Spring projects within an IDE? Perhaps the wiki improvements could go there.
When running a Spring GraphQL service with Spring Boot 3.2 and VS Code's Run and Debug feature,
spring-graphql
throwsIllegalArgumentException
when requests are handled by a controller method with an@Argument
annotation.The exception is not thrown when running with VS Code's Run and Debug and Spring Boot downgraded to 3.1.11.
The exception is not thrown when running with Gradle e.g.
./gradlew bootRun
and Spring Boot 3.2.Steps to reproduce:
Install VS Code with "Extension Pack for Java" and "Gradle for Java" extensions.
Get the code for the Spring Guide GraphQL service in Java using Spring for GraphQL:
https://github.com/spring-guides/gs-graphql-server/tree/main
Open the
complete
folder in VS CodeGo to the Run and Debug view (click its icon in the Activity Bar on the left or press
ctrl-shift-d
orcommand-shift-d
)Click the Run and Debug button and choose
Java
if prompted (or click "create a launch.json file", chooseGraphqlServerApplication
from the RUN AND DEBUG dropdown, and click the Start Debugging button or press F5)Open http://localhost:8080/graphiql in a browser and submit a query via GraphiQL e.g.
query { bookById(id: "book-1") { id } }
The error & stack trace appears in the log:
I believe the problem is related to the Parameter Name Retention change in Spring Framework 6.2:
https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention
The upgrade guidance contains potential solutions for IntelliJ IDEA and Eclipse IDE but no mention of Visual Studio Code. I've looked for some way to configure VS Code to add the recommended
-parameters
parameter to the Java compiler when Run and Debug is used, but I have not been able to find a way to do this.