grpc-ecosystem / grpc-spring

Spring Boot starter module for gRPC framework.

Home Page:https://grpc-ecosystem.github.io/grpc-spring/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace obsolete @PostConstruct annotation or implement InitializingBean

onyn opened this issue · comments

commented

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.

commented

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