How can I get session from a common class in Spring Boot?

If I understand you right, you want to access something in the session scope from a component that a broader scope (singleton), as such the system can't know which one of the potential concurrent sessions in ther server you are interrested in an practically it would say at spring init time that the session scope isn't defined.

You can get arround that with the ObjectFactory pattern (1 of the possible solution)

@Autowired
ObjectFactory<HttpSession> httpSessionFactory;

And then when you need it, from a thread that is bound to the session:

HttpSession session = httpSessionFactory.getObject();

This way spring bind a receipe to get the object you need at the type you call the getObject() method rather than the actual object that is not yet available.

Please understand that if there no session bound to the current thread when you run the code, this will fail (return null) as no session is available. This mean either you call this code from a thread that you failed to forward the request thread local information of the request/session or you call this code from a context where it doesn't make sense.