Skip to content

fix(pom): re-enable -parameters compiler flag#1

Merged
hendrikebbers merged 1 commit into
mainfrom
restore-compiler-parameters-flag
Jul 16, 2026
Merged

fix(pom): re-enable -parameters compiler flag#1
hendrikebbers merged 1 commit into
mainfrom
restore-compiler-parameters-flag

Conversation

@herbie-bot

Copy link
Copy Markdown

Problem

Commit d43152f ("remove unused maven plugins from pom.xml to streamline build configuration") removed the maven-compiler-plugin configuration:

<configuration>
    <parameters>true</parameters>
</configuration>

on the assumption it was unused. It is not unused. Spring relies on formal parameter names being present in the bytecode (-parameters) to:

  • resolve constructor/method injection by name — including disambiguating two beans of the same type by the parameter name,
  • bind @RequestParam / @PathVariable without an explicit name,
  • perform @ConfigurationProperties constructor binding.

Spring Boot's own spring-boot-starter-parent enables -parameters by default for exactly this reason.

Impact

After bumping spring-services to parent 1.2.0, the whole spring-services-core test suite failed at ApplicationContext load (103 errors):

NoUniqueBeanDefinitionException: No qualifying bean of type
'…JsonAuthenticationEntryPoint' available: expected single matching bean
but found 2: jwtAuthenticationEntryPoint, apiKeyAuthenticationEntryPoint

Two beans of the same type could no longer be told apart, because Spring's by-name fallback needs the parameter names that -parameters preserves.

Fix

Re-add the flag as the maven.compiler.parameters property (honored by maven-compiler-plugin 3.15.0), consistent with how maven.compiler.source / maven.compiler.target are declared.

Verification

Built spring-services against this patched parent (1.3.0-SNAPSHOT): the previously-failing module now passes — 294 tests, 0 errors, BUILD SUCCESS.

Note: the same removal commit also dropped a maven-surefire-plugin --add-opens argLine. That is unrelated to this failure and is intentionally not restored here.

🤖 Generated with Claude Code

Commit d43152f ("remove unused maven plugins") dropped the maven-compiler-plugin
<parameters>true</parameters> configuration, assuming it was unused. It is not:
Spring relies on formal parameter names being present in the bytecode to resolve
constructor/method injection by name — e.g. to disambiguate two beans of the same
type by the parameter name, and to bind @RequestParam/@PathVariable/@ConfigurationProperties
without an explicit name. Spring Boot's own parent enables -parameters by default
for exactly this reason.

Without the flag, downstream Spring projects fail at ApplicationContext load with
NoUniqueBeanDefinitionException (observed in spring-services after bumping to parent
1.2.0: two JsonAuthenticationEntryPoint beans could no longer be told apart).

Re-added as the maven.compiler.parameters property (honored by maven-compiler-plugin
3.15.0), consistent with how maven.compiler.source/target are declared.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hendrikebbers added a commit to OpenElementsLabs/spring-services that referenced this pull request Jul 16, 2026
…ualifier

SecurityConfig defines two beans of type JsonAuthenticationEntryPoint
(jwtAuthenticationEntryPoint, apiKeyAuthenticationEntryPoint) and relied on
the injection-point parameter name matching the bean name to pick the right
one. That only works when classes are compiled with -parameters; the org
parent stopped providing that flag in 1.2.0, so the ApplicationContext failed
to load with NoUniqueBeanDefinitionException (103 test errors).

Resolve the ambiguity explicitly with @qualifier instead of relying on
parameter-name magic, so the wiring is correct and self-documenting
regardless of the compiler flag. The parent is separately being fixed to
re-enable -parameters (OpenElementsLabs/java-parent#1), but this makes the
security config robust on its own.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hendrikebbers
hendrikebbers merged commit dab6414 into main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants