求救:spring+hibernate的demo里报错:“class org.springframework.beans.factory.NoSuchBeanDefinitionException”,解决了就揭帖! 你的spring-config.xml文件及web.xml文件也贴出来看看! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 请问三楼的,你要看struts-config.xml文件还是spring-config.xml啊?我这里好像没有spring-config.xml文件,只有applicationContext.xml文件,其实 protected ICompanyService getCompanyService(){ return (ICompanyService)AppContext.getInstance().getAppContext().getBean("companyService"); }这个方法调用的就是:public class AppContext { private static AppContext instance; private AbstractApplicationContext appContext; public synchronized static AppContext getInstance() { if (instance == null) { instance = new AppContext(); } return instance; } private AppContext() { this.appContext = new ClassPathXmlApplicationContext( "/applicationContext.xml"); } public AbstractApplicationContext getAppContext() { return appContext; }} 其实我认为这个问题本质还是出在hibernate那一层。有人认同吗? 应该是spring的配置文件定义bean时的问题吧,看看是不是哪个没定义啊? 假如你去掉了 OnlineStat.hbm.xml 就可以了那么应该是你在 OnlineStat.hbm.xml 这里面出了问题。 这个可能是spring没有找到*.hbm.xml文件。 NoSuchBeanDefinitionException查查Bean的定义是否正确? 换了一种IDE了,原来的classpath也变了(不同的工具默认的classpath也是不一样的),正如programeyonger所说是因为spring没有找到*.hbm.xml文件,我把那个文件放到jb的class目录下就好了。谢谢热心的朋友!! jbpm4.4怎么获取最新版本的流程 java.lang.NoSuchMethodException: $Proxy13.get()帮忙看看。。 filter 拦截这后怎样跳出框架 关于JAVA EE,书上自带案例语句不懂 求救 QUARTZ? struts2 in action 源代码部署到myeclipse上 用jxl如何读excel表写入数据库,且excel表与数据表内容不是一一对应,excel表字段少 J2EE 连接ORACLE 数据库与连接XML哪个效率高一些? 大家对JAVA P2P了解多吗? 讨论EJB群!10057492 欢迎加入! 求教两个hibernate的方法
return (ICompanyService)AppContext.getInstance().getAppContext().getBean("companyService");
}
这个方法调用的就是:
public class AppContext { private static AppContext instance; private AbstractApplicationContext appContext; public synchronized static AppContext getInstance() {
if (instance == null) {
instance = new AppContext();
}
return instance;
} private AppContext() {
this.appContext = new ClassPathXmlApplicationContext(
"/applicationContext.xml");
} public AbstractApplicationContext getAppContext() {
return appContext;
}
}
那么应该是你在 OnlineStat.hbm.xml 这里面出了问题。
谢谢热心的朋友!!