Skip to content
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

Replace obsolete @PostConstruct annotation or implement InitializingBean #1044

Closed
onyn opened this issue Jan 31, 2024 · 1 comment
Closed
Labels
enhancement A feature request or improvement

Comments

@onyn
Copy link
Contributor

onyn commented Jan 31, 2024

The problem

Some autoconfiguration classes uses obsolete javax.annotation.PostConstruct annotation (e.g. GrpcMetadataConsulConfiguration).

Spring boot 3 still supports it, but doesn't include corresponding dependency. And because of this, configuration classes won't load. So I need to include javax.annotation:javax.annotation-api:1.3.2 dependency explicitly in my project to make this work. This is tedious and human factor prone.

The solution

Two solutions available:

  1. Remove annotation entirely and implement org.springframework.beans.factory.InitializingBean interface.
  2. Replace javax.annotation.PostConstruct with jakarta.annotation.PostConstruct. Spring boot includes jakarta.annotation dependency since release 2.2 and drops javax.annotation since 3.0.

Additional context

This ticket relates to #778.

I could make PR. But one of proposed solutions should be chosen first. I personally prefer option 1. IMHO it's more reliable since annotations have been already broken once and I never heard that spring broke InitializingBean in some way.

@onyn onyn added the enhancement A feature request or improvement label Jan 31, 2024
@onyn
Copy link
Contributor Author

onyn commented Jan 31, 2024

Oh, I see it's already done in 98f29e4.

@onyn onyn closed this as completed Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request or improvement
Projects
None yet
Development

No branches or pull requests

1 participant