Skip to content

Gradle Kotlin DSL - Spring boot - parameter not working [java.lang.IllegalArgumentException: Name for argument of type...] - Integration Test #41992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
drakgoku opened this issue Aug 21, 2024 · 4 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@drakgoku
Copy link

I'm posting it here because I don't know who's fault it is, whether it's Srping or Gradle's.

gradle/gradle#30267

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 21, 2024
@drakgoku
Copy link
Author

drakgoku commented Aug 21, 2024

Check the method parameters annotation:
Make sure that the method that is causing the problem has the parameters correctly annotated.

In my case in the controller:

@GetMapping(value = { path + "/{id}" })
public ResponseEntity<?> findById(@PathVariable Long id) {

I have to specify the variable name for integration tests. It seems that it is mandatory.

@GetMapping(value = { path + "/{id}" })
public ResponseEntity<?> findById(@PathVariable("id") Long id) {

We changed
(@PathVariable Long id) to (@PathVariable("nameParameter") Long id).

And:

     tasks.withType<JavaCompile>().configureEach {

        options.compilerArgs.add("-parameters")
    }

I seem to remember that in the past it was not necessary.

@scottfrederick
Copy link
Contributor

scottfrederick commented Aug 21, 2024

@scottfrederick scottfrederick added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged status: duplicate A duplicate of another issue labels Aug 21, 2024
@drakgoku
Copy link
Author

See spring-projects/spring-framework#31675

I'll clarify the duplicate case.
It's not really a duplicate even though it may seem like it.

The fact of having the "-parameters" didn't make it work as I explained in the post that I suppose you've read.

and as I put in this post, you have to specify the name of the parameter ("nameParams") to the parameter type. Otherwise, it won't work no matter how much you have "-parameters"

Regards.

@scottfrederick
Copy link
Contributor

I removed the duplicate tag right after I added it, because I realized it might not be a true duplicate of the linked issue. Regardless of that, the behavior you are describing is in Spring Framework, and Spring Boot has no control over it. If you have further questions about how this is working, the Spring Framework issue tracker or StackOverflow would be the places to follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants