java - Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException -
this main class not working
main.java
package com.simpleclass; import org.springframework.beans.factory.beanfactory; import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; public class main { /** * @param args */ public static void main(string[] args) { // todo auto-generated method stub //load beans.xml file project's classpath system.out.print("hi"); applicationcontext context = new classpathxmlapplicationcontext( "beans.xml"); beanfactory factory = (beanfactory) context; //build factory //obtain bean factory hellospring hellospring = (hellospring) factory.getbean("hellospring"); //most of heavy lifting done spring, use hellospring object wish hellospring.sayhello(); } } beans.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> <bean id="hellospring" class="com.simpleclass.hellospring"> <property name="message" value="hello spring!" /> </bean> </beans> i create simple spring application, can start application simple message printing error occures. can 1 tell me need do? thanks
19 apr, 2013 12:33:34 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions info: loading xml bean definitions class path resource [beans.xml] exception in thread "main" org.springframework.beans.factory.beandefinitionstoreexception: line 5 in xml document class path resource [beans.xml] invalid; nested exception org.xml.sax.saxparseexception: document root element "beans", must match doctype root "null". org.xml.sax.saxparseexception: document root element "beans", must match doctype root "null". @ com.sun.org.apache.xerces.internal.util.errorhandlerwrapper.createsaxparseexception(unknown source) @ com.sun.org.apache.xerces.internal.util.errorhandlerwrapper.error(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmlerrorreporter.reporterror(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmlerrorreporter.reporterror(unknown source) @ com.sun.org.apache.xerces.internal.impl.dtd.xmldtdvalidator.rootelementspecified(unknown source) @ com.sun.org.apache.xerces.internal.impl.dtd.xmldtdvalidator.handlestartelement(unknown source) @ com.sun.org.apache.xerces.internal.impl.dtd.xmldtdvalidator.startelement(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl.scanstartelement(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$contentdriver.scanrootelementhook(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$prologdriver.next(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl.next(unknown source) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl.scandocument(unknown source) @ com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(unknown source) @ com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(unknown source) @ com.sun.org.apache.xerces.internal.parsers.xmlparser.parse(unknown source) @ com.sun.org.apache.xerces.internal.parsers.domparser.parse(unknown source) @ com.sun.org.apache.xerces.internal.jaxp.documentbuilderimpl.parse(unknown source) @ javax.xml.parsers.documentbuilder.parse(unknown source) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:126) @ org.springframework.context.support.abstractxmlapplicationcontext.loadbeandefinitions(abstractxmlapplicationcontext.java:125) @ org.springframework.context.support.abstractxmlapplicationcontext.refreshbeanfactory(abstractxmlapplicationcontext.java:65) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:226) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:58) @ com.simpleclass.main.main(main.java:17)
Comments
Post a Comment