日期:2014-05-20  浏览次数:20908 次

最低级的spring例子中出现的错误,求大神。
自己写了一个xml,准备用于spring中,但是eclipse提示有错误。求大神赐教。错误如下描述。

applicationContent.xml内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean id="colorInk" 
class="mypackage.ColorInk" >
</bean>
<bean id="grayInk" 
class="mypackage.GrayInk" >
</bean>

<bean id="a4Paper" class="mypackage.TextPaper">
<property name="charPerLine" value="10" />
<property name="linePerPage" value="8" />
</bean>

<bean id="b5Paper" class="mypackage.TextPaper">
<property name="charPerLine" value="6" />
<property name="linePerPage" value="5" />
</bean>

<bean id="printer" class="mypackage.Printer">
<property name="ink" ref="colorInk" />
<property name="paper" ref="b5Paper" />
</bean>

</beans>

错误:can't connect to SOCKS proxy:Connection refused :connect
错误指示在这一行:class="mypackage.ColorInk" >

越过这个错误提示进行运行,则出现错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:161)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:90)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at SpringTest.main(SpringTest.java:13)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 7 more

------解决方案--------------------
你没有把你引用的包部署在web服务器上
org/apache/commons/logging/LogFactory

就是这个