spring企业应用论坛搭建遇到的问题

1.解决Failed to load class “org.slf4j.impl.StaticLoggerBinder”

hibernate工程里面使用的是hibernate3.3.1的Lib。
提示信息中多次提到SLF4J,google了一下,才发现这是现在的Hibernate使用SLF4J API记录日志,所以在Hibernate的lib中,不再提供Log4J的包,而大部分框架依然使用Log4J记录日志,这样导致了兼容性问题。
解决办法,两步:

    一、在编译路径中添加Log4J的包,比如我一直在用的log4j-1.2.8.jar; 

    二、再添加一个叫做slf4j-log4j12-1.5.11.jar的包进行转换,注意到这里的log4j12,可能对应的是log4j 1.2版本。 

补充:
SLF4J官方下载:http://www.slf4j.org/download.html
下载对应版本后加压找到slf4j-log4j12-XX.jar即可

2.解决java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;[Ljava

关于Logback的一个异常
java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;[Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
原因可能有两个:
1、jar包冲突,build path下可能加入了 slf4j-log4或者 log4j的jar包,删除即可。

2、jar包版本导致的,例如 如果你的Logback是1.0.6版本,那么你的slf4j需要[1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11]版本的。
SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11]
不管是Logback版本高还是slf4j的低只要找对匹配的版本即可。

3.解决The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

JSP页面顶端出现“红色”的报错信息:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path。原来Javaweb工程类中没有添加Tomcat运行时相关类导致。
下面是具体的解决方法:
1、右击web工程-》属性或Build Path-》Java Build Path->Libraries-> Add Libray…->Server Runtime -》Tomcat Server
2、切换到Java Build Path界面中的Orader and Export,选择Tomcat。

注意:
按以上方法操作时,若打开Server Runtime后一片空白,需要设置Apache服务器。设置方法为:window->Preferences->Server->Runtime Environment -> add –> 选择Apache的版本后点Next,再填入你apache服务器软件的安装(解压后)地址。

4.解决java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL,spring获取context
ava虚拟机是根据Java ClassLoader(类加载器)决定如何加载Class。
系统默认提供了3个ClassLoader
Root ClassLoader,ClassPath Loader,Ext ClassLoader
我们也可以编写自己的ClassLoader,去加载特定环境下的Jar文件。
能不能加载Jar,加载哪里的Jar,是由ClassLoader决定的。

楼主的问题可能是 导入的仅仅是jar包的引用,例如在eclipse中通过build path加进user lib……(类似快捷方式)
这种在Java Application中没问题,但在web Application中可能会出现找不到类的异常。
在WEB Application中jar包最好放在webroot或webcontent下的lib文件夹内,特别是xml中用到的jar包。

javalangClassNotFoundException: orgspringframeworkwebcontextContextLoa
spring-web 的jar包没导进去
jar包邮冲突,把重复的jar包删除
在web.xml加上 contextConfigLocation classpath:applicationContext-*.xml
因为默认的读取的是/WEB-INF下的配置文件,如果配置文件在src中要把路径改为类路径底下
4.把工程刷新一下,因为工程是部署在服务器底下的,要把加入的jar包部署到工程里。

启动报错:javalangClassNotFoundException: orgspringframeworkwebcontextContextLoaderListener
jar包不是导入进去就完了,还要buildpath,也就是创建路径。在Myeclipse里面,右键单击你的jar包,点击build path–》add build path。完成创建路径。另外spring的jar包并非只有一个,最基本的有3个。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值