Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

enforce loading spring beans with default-lazy-init=true

View LazyBeanDefinitionDocumentReader.java
1 2 3 4 5 6 7 8 9
public class LazyBeanDefinitionDocumentReader extends DefaultBeanDefinitionDocumentReader {
 
@Override
protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
root.setAttribute("default-lazy-init", "true");
BeanDefinitionParserDelegate delegate = super.createHelper(readerContext, root, parentDelegate);
return delegate;
}
}
View LazyBeanDefinitionDocumentReader.java
1 2 3 4 5 6 7 8 9 10 11 12
public class LazyClassPathXmlApplicationContext extends ClassPathXmlApplicationContext {
 
public LazyClassPathXmlApplicationContext(String path) throws BeansException {
super(path);
}
 
@Override
protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
super.initBeanDefinitionReader(reader);
reader.setDocumentReaderClass(LazyBeanDefinitionDocumentReader.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.