1 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.
2 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
3 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
4 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
5 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
6 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
7 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
8 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
9 at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:212)
10 at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:189)
11 at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:169)
12 at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:140)
13 at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:98)
14 at junit.framework.TestCase.runBare(TestCase.java:132)
15 at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
16 at junit.framework.TestResult 1. p r o t e c t ( T e s t R e s u l t . j a v a : 110 ) 17 a t j u n i t . f r a m e w o r k . T e s t R e s u l t . r u n P r o t e c t e d ( T e s t R e s u l t . j a v a : 128 ) 18 a t j u n i t . f r a m e w o r k . T e s t R e s u l t . r u n ( T e s t R e s u l t . j a v a : 113 ) 19 a t j u n i t . f r a m e w o r k . T e s t C a s e . r u n ( T e s t C a s e . j a v a : 124 ) 20 a t j u n i t . f r a m e w o r k . T e s t S u i t e . r u n T e s t ( T e s t S u i t e . j a v a : 243 ) 21 a t j u n i t . f r a m e w o r k . T e s t S u i t e . r u n ( T e s t S u i t e . j a v a : 238 ) 22 a t o r g . j u n i t . i n t e r n a l . r u n n e r s . J U n i t 38 C l a s s R u n n e r . r u n ( J U n i t 38 C l a s s R u n n e r . j a v a : 83 ) 23 a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t 4. r u n n e r . J U n i t 4 T e s t R e f e r e n c e . r u n ( J U n i t 4 T e s t R e f e r e n c e . j a v a : 50 ) 24 a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . T e s t E x e c u t i o n . r u n ( T e s t E x e c u t i o n . j a v a : 38 ) 25 a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n T e s t s ( R e m o t e T e s t R u n n e r . j a v a : 467 ) 26 a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n T e s t s ( R e m o t e T e s t R u n n e r . j a v a : 683 ) 27 a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n ( R e m o t e T e s t R u n n e r . j a v a : 390 ) 28 a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . m a i n ( R e m o t e T e s t R u n n e r . j a v a : 197 ) 29 C a u s e d b y : o r g . x m l . s a x . S A X P a r s e E x c e p t i o n : c v c − e l t . 1 : C a n n o t f i n d t h e d e c l a r a t i o n o f e l e m e n t ′ b e a n s ′ . 30 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . u t i l . E r r o r H a n d l e r W r a p p e r . c r e a t e S A X P a r s e E x c e p t i o n ( E r r o r H a n d l e r W r a p p e r . j a v a : 195 ) 31 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . u t i l . E r r o r H a n d l e r W r a p p e r . e r r o r ( E r r o r H a n d l e r W r a p p e r . j a v a : 131 ) 32 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . X M L E r r o r R e p o r t e r . r e p o r t E r r o r ( X M L E r r o r R e p o r t e r . j a v a : 384 ) 33 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . X M L E r r o r R e p o r t e r . r e p o r t E r r o r ( X M L E r r o r R e p o r t e r . j a v a : 318 ) 34 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . x s . X M L S c h e m a V a l i d a t o r . h a n d l e S t a r t E l e m e n t ( X M L S c h e m a V a l i d a t o r . j a v a : 1887 ) 35 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . x s . X M L S c h e m a V a l i d a t o r . s t a r t E l e m e n t ( X M L S c h e m a V a l i d a t o r . j a v a : 685 ) 36 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . X M L N S D o c u m e n t S c a n n e r I m p l . s c a n S t a r t E l e m e n t ( X M L N S D o c u m e n t S c a n n e r I m p l . j a v a : 400 ) 37 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . X M L N S D o c u m e n t S c a n n e r I m p l 1.protect(TestResult.java:110) 17 at junit.framework.TestResult.runProtected(TestResult.java:128) 18 at junit.framework.TestResult.run(TestResult.java:113) 19 at junit.framework.TestCase.run(TestCase.java:124) 20 at junit.framework.TestSuite.runTest(TestSuite.java:243) 21 at junit.framework.TestSuite.run(TestSuite.java:238) 22 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) 23 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 24 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 25 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 26 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 27 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 28 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 29 Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'. 30 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 31 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) 32 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) 33 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) 34 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1887) 35 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685) 36 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400) 37 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl 1.protect(TestResult.java:110)17atjunit.framework.TestResult.runProtected(TestResult.java:128)18atjunit.framework.TestResult.run(TestResult.java:113)19atjunit.framework.TestCase.run(TestCase.java:124)20atjunit.framework.TestSuite.runTest(TestSuite.java:243)21atjunit.framework.TestSuite.run(TestSuite.java:238)22atorg.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)23atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)24atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)25atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)26atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)27atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)28atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)29Causedby:org.xml.sax.SAXParseException:cvc−elt.1:Cannotfindthedeclarationofelement′beans′.30atcom.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)31atcom.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)32atcom.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)33atcom.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)34atcom.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1887)35atcom.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685)36atcom.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)37atcom.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImplNSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
38 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl F r a g m e n t C o n t e n t D r i v e r . n e x t ( X M L D o c u m e n t F r a g m e n t S c a n n e r I m p l . j a v a : 3095 ) 39 a t c o m . s u n . o r g . a p a c h e . x e r c e s . i n t e r n a l . i m p l . X M L D o c u m e n t S c a n n e r I m p l FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095) 39 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095)39atcom.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImplPrologDriver.next(XMLDocumentScannerImpl.java:921)
40 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
41 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
42 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
43 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
44 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
45 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
46 at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
47 at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
48 at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
49 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
50 … 26 more
今天出现了一个bug,如上图所示 说我第十航有问题??
研究来研究去发现 是由于 第十行的约束没有导入,导入了之后运行就没有问题了。
后来又把第十行的约束删除了之后运行,又不报错了。
一般来说,出现此类问题,自己一定要学会导入约束,一般都是约束处出现了问题