log4j:WARN No appenders could be found for logger (org.springframework.beans.factory.xml.XmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Passed-in Resource [resource loaded through InputStream] contains an open stream: cannot determine validation mode automatically. Either pass in a Resource that is able to create fresh streams, or explicitly specify the validationMode on your XmlBeanDefinitionReader instance.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.detectValidationMode(XmlBeanDefinitionReader.java:457)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.getValidationModeForResource(XmlBeanDefinitionReader.java:438)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:395)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at person.BeanTest.main(BeanTest.java:20)报错
配置文件:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><bean id="chinese" class="person.Chinese"/>
<property name="axe">
<ref local="steelAxe"/>
</property>
</bean>
<!--
<property name="num" value="12"/>
-->
<bean id="steelAxe" class="person.SteelAxe" /></beans>
代码:
package person;import java.io.FileInputStream;
import java.io.InputStream;import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.InputStreamResource;public class BeanTest { /**
* @param args
*/
public static void main(String[] args) throws Exception {
InputStream is =new FileInputStream("applicationContext.xml");
InputStreamResource isr=new InputStreamResource(is);
XmlBeanFactory factory =new XmlBeanFactory(isr);
System.out.println(" shilihua BeanFactory");
Person p=(Person)factory.getBean("chinese");
System.out.println(" shilihua BeanFactory");
p.useAxe();
}
}
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Passed-in Resource [resource loaded through InputStream] contains an open stream: cannot determine validation mode automatically. Either pass in a Resource that is able to create fresh streams, or explicitly specify the validationMode on your XmlBeanDefinitionReader instance.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.detectValidationMode(XmlBeanDefinitionReader.java:457)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.getValidationModeForResource(XmlBeanDefinitionReader.java:438)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:395)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at person.BeanTest.main(BeanTest.java:20)报错
配置文件:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><bean id="chinese" class="person.Chinese"/>
<property name="axe">
<ref local="steelAxe"/>
</property>
</bean>
<!--
<property name="num" value="12"/>
-->
<bean id="steelAxe" class="person.SteelAxe" /></beans>
代码:
package person;import java.io.FileInputStream;
import java.io.InputStream;import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.InputStreamResource;public class BeanTest { /**
* @param args
*/
public static void main(String[] args) throws Exception {
InputStream is =new FileInputStream("applicationContext.xml");
InputStreamResource isr=new InputStreamResource(is);
XmlBeanFactory factory =new XmlBeanFactory(isr);
System.out.println(" shilihua BeanFactory");
Person p=(Person)factory.getBean("chinese");
System.out.println(" shilihua BeanFactory");
p.useAxe();
}
}
解决方案 »
- javaMail 发送附件
- servlet问题 为啥不能运行啊服务器是tomcat6.0
- 关于SSH框架 自定义表单重复提交 token拦截器的问题
- 帮忙解决个听起来很简单但是又很棘手的问题。
- eclipse2.1.2可以运行,3.0m6,m7不能运行,出现错误,谁碰到过,请帮忙
- 如何在Tomcat4.1.27中使用Struts1.1开发时配置Ant?我这边老报错。在线。。。
- 做报表哪种比较好用?
- 关于报表的问题?
- 谁能介绍一下子Tiles呀?
- 请提供基本介绍j2ee入门的书??
- spring好像没有注入,一直出现在空指针,很简单的,以前好好的~~~
- struts2 spring2.5 hibernate3.2 整合异常
Exception in thread "main" java.io.FileNotFoundException: classpath:\applicationContext.xml (文件名、目录名或卷标语法不正确。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at person.BeanTest.main(BeanTest.java:15)
还是不对啊
Person p=(Person)factory.getBean("chinese");试试这个