I get userId from request.getRemoteUser(), I want to store it somewhere and get from any layer of application. I don't want to pass the userId from controller to other layers or store it in context. Is there anything similar to this, so that simply autowired userId and use it anywhere. I'm using Spring-boot and Spring-rest controller.
@Configuration
public class ConfigurationClass {
private @Value("#{ request.getRemoteUser() }") String userId;
@Bean("userId")
@Scope("request")
public String getUserId() {
return userId;
}