applicationcontext ctx = new classpathxmlapplicationcontext("applicationcontext.xml");
<beans>
<bean id="default-context" class="org.springframework.context.support.classpathxmlapplicationcontext">
<constructor-arg>
<list> <value>applicationcontext.xml</value></list>
</constructor-arg>
</bean>
</beans>
beanfactoryreference bfr = defaultlocatorfactory.getinstance().usebeanfactory("default-context");
beanfactory factory = bfr.getfactory();
myservice myservice = factory.getbean("myservice");
bfr.release();
// now use myservice
public void contextinitialized(servletcontextevent event)
{
super.contextinitialized(event);
servletcontext context = event.getservletcontext();
applicationcontext ctx = webapplicationcontextutils.getrequiredwebapplicationcontext(context);
contextutil.setcontext(ctx);
}
applicationcontext context = contextutil.getcontext();
新闻热点
疑难解答