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:
Remove annotation entirely and implement org.springframework.beans.factory.InitializingBean interface.
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.
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:
org.springframework.beans.factory.InitializingBean
interface.javax.annotation.PostConstruct
withjakarta.annotation.PostConstruct
. Spring boot includesjakarta.annotation
dependency since release 2.2 and dropsjavax.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.