2016-09-07 3 views
0

Spring XML 구성에서 애플리케이션 컨텍스트 클래스 로더를 가져와 다른 bean의 param처럼 설정하는 방법은 무엇입니까? 자바 코드에서 난xml의 Spring 컨텍스트 클래스 로더

@Autowired 
ApplicationContext context 
... 
{ 
    ClassLoader classLoader = context.getClassLoader(); 
} 
+1

귀하의 질문은 매우 모호합니다. 정확히 무엇을하고 싶습니까? – kuhajeyan

+0

'BeanClassLoaderAware' 만 구현하면됩니다. –

답변

3

컨테이너 빈을 사용하지 않는 이유는 무엇입니까?

@bean 
public class ClassLoaderHolderBean implements ClassLoaderHolder { 
    @Autowired 
    ApplicationContext context; 

    @override 
    public ClassLoader getClassLoader() { 
    return context.getClassLoader(); 
    } 
} 

그런 다음이 빈을 필요한 곳에 주입하십시오.

+0

스마트 솔루션, 고마워요. – jenius