1.1
tj
2025-06-05 77c1b2e42b966f6ac3781efceb2cffdd590addec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.mzl.flower.config.security;
 
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
 
@Component
public class SpringSecurityUtils implements ApplicationContextAware {
    public static ApplicationContext applicationContext = null;
 
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (SpringSecurityUtils.applicationContext == null) {
            SpringSecurityUtils.applicationContext = applicationContext;
        }
    }
 
    public static <T> T getBean(Class<T> clazz) {
        return applicationContext.getBean(clazz);
    }
}