I am trying to get Spring active profile in JPA
Entity Listener using System.getproperty("spring.profiles.active")
. But it is always returning Null profile. However I have checked on server and profile is correctly configured.
I have tried to get Spring active profile using Environment but in the listener, I am unable to @Autowired
Environment also.
@PostUpdate
public void methodInvoked afterUpdate(Example example){
String activeProfile = System.getproperty("spring.profiles.active");
}
Any guidance please !
@Value
or autowireEnvironment
instead: #9268299 – Calendar@Value
orEnvironment
does not work. As @Karol Dowbecki mentioned I have to explicitly need to inject the Dependency in my Listener class. – Gardiner