Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:971)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at com.huawei.rcs.netdisk.test.Test.main(Test.java:45)
代码如下:
public class Test {
public static void main(String[] args) throws IOException {
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] {"*/spring-com-huawei-rcs-netdisk-dao.xml","*/spring-dataSource.xml"});
//BeanFactory factory = (BeanFactory) context;
org.springframework.orm.hibernate3.LocalSessionFactoryBean dao = (org.springframework.orm.hibernate3.LocalSessionFactoryBean)context.getBean("sessionFactory");
。。。。。