I have a spring boot version 3.1.4 application running with java 17
This application has a dependency in its pom.xml which is an application written in java 8
The java 8 dependency application uses the PostConstruct annotation from below import
import javax.annotation.PostConstruct
The problem is my spring boot 3 application running in java 17 never executes the function marked with @PostConstruct in the dependency.
This issue does not occur when I downgrade my application from spring boot 3 to spring boot 2 and run it using java 17
How can I fix this issue?
This would be because in spring boot 3 moved from javax to jarkarta. This would mean that you would have to use
import jakarta.annotation.PostConstruct instead of javax.annotation.PostConstruct
You might have to get the updated version of the dependency that is compatible with spring boot 3 and java 17
You can take a look at this
https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x