关于spring 入门级问题 spring 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 NoClassDefFoundError说你没有定义bean,你确定beans-config.xml放的位置正确,能正常初始化XmlBeanFactory? 配置文件时,要认真点:<bean id="helloBean" class="onlyfun.caterpillar.Hellobean">class配错了,认真看看。log4j那些警告不影响使用,要配正确的话,需要在classPath中加入 log4j.properties文件,文件内容可以百度一下。可能还需要初始化 log4j,这个忘记了是不是必须的。 劝你还是重sping3或4学起吧,太老的东西有的都淘汰了,等你学完还得尝试忘记学过的东西。。 学学spring4吧,功能太强大了,很好 各位有什么好点的书籍推荐一下?关于spring4的,我是菜,从入门开始 <bean id="helloBean" class="onlyfun.caterpillar.Hellobean"> public class SpringDemo { /** * @param args */ public static void main(String[] args) { ApplicationContext ct= new ClassPathResource("applicationContext.xml"); ///创建此对象 HelloBean hello = (HelloBean) ct.getBean("helloBean"); System.out.println(hello.getHelloword()); } }////这个才是正确的获取applicationContext.xml配置文件中的内容 NoClassDefFoundError 这个错误常见有两种情况:1、我们搞错了大小写,Java 区分大小写但 Windows 操作系统不区分大小写,因此经常出现 class found 但却 No def 错误。2、我们在第一次访问这个类时它的某个 static 变量赋值时出现了 exception 未处理或者 static {} 块中抛出异常,这就导致这个 found 但 no def,当代码第2次再来尝试访问这个类时就得到 NoClassDefFoundError 。 Java程序员进入腾讯的必备条件 向struts2传递数组 关于JSP中汉字显示。 Socket 客服端,怎么判断已经和服务端断开 求一个获得上传文件名的例子 取SqlServer中为空的字段的数据报错 jsp中连接oracle的问题---菜鸟求助 jxl操作Excel文件,能不能做出查寻功能呀? 急呀 xfire的webservice,各位大神来看看啊 这个问题还是没人能帮我吗? 页面上大段文章自动上移或者翻页的问题 tomcat daemon方式启动,ckfinder上传中文文件乱码问题
说你没有定义bean,你确定beans-config.xml放的位置正确,能正常初始化XmlBeanFactory?
<bean id="helloBean" class="onlyfun.caterpillar.Hellobean">
class配错了,认真看看。log4j那些警告不影响使用,要配正确的话,需要在classPath中加入 log4j.properties文件,文件内容可以百度一下。
可能还需要初始化 log4j,这个忘记了是不是必须的。
/**
* @param args
*/
public static void main(String[] args) { ApplicationContext ct= new ClassPathResource("applicationContext.xml"); ///创建此对象
HelloBean hello = (HelloBean) ct.getBean("helloBean");
System.out.println(hello.getHelloword());
}
}
////这个才是正确的获取applicationContext.xml配置文件中的内容
NoClassDefFoundError 这个错误常见有两种情况:
1、我们搞错了大小写,Java 区分大小写但 Windows 操作系统不区分大小写,因此经常出现 class found 但却 No def 错误。
2、我们在第一次访问这个类时它的某个 static 变量赋值时出现了 exception 未处理或者 static {} 块中抛出异常,这就导致这个 found 但 no def,当代码第2次再来尝试访问这个类时就得到 NoClassDefFoundError 。