Skip to content

Adopt @AutoConfiguration in components-starter#1752

Merged
Croway merged 2 commits intoapache:mainfrom
Croway:quick-fix/adopt-autoconfiguration-components-starter
Apr 16, 2026
Merged

Adopt @AutoConfiguration in components-starter#1752
Croway merged 2 commits intoapache:mainfrom
Croway:quick-fix/adopt-autoconfiguration-components-starter

Conversation

@Croway
Copy link
Copy Markdown
Contributor

@Croway Croway commented Apr 15, 2026

Summary

Follow-up to #1751. Extends the @AutoConfiguration adoption from the core module to the components-starter modules and the code generator.

  • Generator plugin (SpringBootAutoConfigurationMojo): now emits @AutoConfiguration(after=...) with constructor injection instead of @Configuration(proxyBeanMethods=false) + @AutoConfigureAfter + @Autowired field injection
  • 30 hand-written auto-configuration classes: migrated to @AutoConfiguration, constructor injection, ObjectProvider for optional dependencies, removed redundant @Scope(SCOPE_SINGLETON)
  • ~473 regenerated files: output of the updated generator

For review readibility:

  • 60caf1c contains only the generated classes (not interesting)
  • dbfab9b contain the actual changes

Test plan

  • Generator plugin builds successfully
  • Regenerated starters (direct, jms) produce correct @AutoConfiguration output with constructor injection
  • Converter classes correctly left unchanged (@Configuration, @Component)
  • Hand-written starters compile (consul-cluster, resilience4j, aws-xray, opentelemetry, direct)
  • Full local build of camel-spring-boot passes

Croway added 2 commits April 15, 2026 11:05
Regenerated output from updated camel-spring-boot-generator-maven-plugin.
All generated auto-configuration classes now use @autoConfiguration(after=...)
instead of @configuration(proxyBeanMethods=false) + @AutoConfigureAfter,
and constructor injection instead of @Autowired field injection.
Follow-up to the core module migration in apache#1751. Updates the code
generator and all hand-written auto-configuration classes in
components-starter to use Spring Boot's @autoConfiguration annotation.

Generator (SpringBootAutoConfigurationMojo):
- Emit @autoConfiguration(after=...) instead of @configuration + @AutoConfigureAfter
- Use constructor injection for all generated fields

Hand-written auto-configurations (30 files):
- Replace @configuration(proxyBeanMethods=false) with @autoConfiguration
- Replace @AutoConfigureAfter/@AutoConfigureBefore with after/before/afterName/beforeName attributes
- Replace @Autowired field injection with constructor injection or ObjectProvider
- Remove redundant @scope(SCOPE_SINGLETON) from cluster service beans
- Fix two CamelMetricsAutoConfiguration classes missing @configuration entirely
- Add ElementType.PARAMETER to @CamelAwsXRayTracingStrategy for ObjectProvider usage

Skipped (correctly kept as @configuration):
- ObservationConditionalAutoConfiguration (loaded via @import, not AutoConfiguration.imports)
- MicrometerObservabilityConditionalAutoConfiguration (same reason)
- All Converter classes (not auto-configurations)
@davsclaus
Copy link
Copy Markdown
Contributor

so this is a more modern SB style

@Croway
Copy link
Copy Markdown
Contributor Author

Croway commented Apr 15, 2026

so this is a more modern SB style

exactly! -500 lines of code is always good :)

it is both a modern approach and some best practices, like avoid Autowired where possible and use constructor injection. this issue describe the changes #1751

@Croway Croway requested a review from cunningt April 15, 2026 09:47
@Croway
Copy link
Copy Markdown
Contributor Author

Croway commented Apr 15, 2026

@mcarlett

@Croway Croway merged commit 136b6c5 into apache:main Apr 16, 2026
5 checks 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