Spring 问题 求解

hq1015050507 2012-06-26 10:27:41
package junit.test;


import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.itcast.service.PersonService;

public class SpringTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@Test public void instanceSpring(){
ApplicationContext ctx=new ClassPathXmlApplicationContext("beans.xml");
PersonService personService=(PersonService)ctx.getBean("personService");
personService.save();
}
}



2012-6-26 10:30:09 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1d1acd3: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1d1acd3]; startup date [Tue Jun 26 10:30:09 CST 2012]; root of context hierarchy
2012-6-26 10:30:09 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [beans.xml]
2012-6-26 10:30:10 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1d1acd3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@12d15a9
2012-6-26 10:30:10 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12d15a9: defining beans [personService]; root of factory hierarchy
2012-6-26 10:30:10 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12d15a9: defining beans [personService]; root of factory hierarchy
...全文
104 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hq1015050507 2012-06-26
  • 打赏
  • 举报
回复
解决了,是beans.xml 配置的问题 谢谢了
HeiBoyYang 2012-06-26
  • 打赏
  • 举报
回复
beans.xml 配置的问题

PersonService personService=(PersonService)ctx.getBean("personService");
能获取到吗?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧