Spring 오류: 요소 "context:component-scan"의 접두사 "context"가 연결되지 않은 문제 해결

Spring 프로필 오류: 요소 "context:component-scan"의 접두사 "context"가 연결되지 않았습니다. 이것은 제가 프로젝트를 할 때 만났던 것입니다. 프로젝트 매니저와 동료의 알림을 통해 해결되었습니다. 여기서 어떻게 해결할지 말씀드리겠습니다.
     1.스프링 구성 정보는 다음과 같습니다.

<?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.xsd"> 
 
  <!--  dao service ( ) --> 
  <<span style="color: #ff00ff;">context:</span>component-scan base-package="com.makelove88.**.dao,com.makelove88.**.service" /> 
  <import resource="classpath*:*/applicationContext-*.xml" /> 
 
 
</beans> 
     2.오류 정보는 다음과 같습니다.

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 8 in XML document from URL [file:/E:/InstallSoftware/tomcat/tomcat7u50_8888/webapps/jms/WEB-INF/classes/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 109;   "context:component-scan"   "context"  。 
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399) 
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) 
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) 
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) 
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) 
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) 
  at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) 
  at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) 
  at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) 
  at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) 
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) 
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) 
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) 
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4961) 
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5455) 
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
  at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
  at java.lang.Thread.run(Thread.java:745) 
Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 109;   "context:component-scan"   "context"  。 
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) 
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) 
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441) 
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) 
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325) 
  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:289) 
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786) 
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) 
  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117) 
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) 
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) 
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) 
  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) 
  at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) 
  at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347) 
  at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76) 
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429) 
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) 
  ... 22 more 
  09, 2016 10:09:32   org.apache.catalina.core.StandardContext listenerStart 
 : Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener 
[문제 분석]
프로필에context 탭이 사용되었지만 선언되지 않았습니다.
[솔루션]
프로필에context 설명을 추가합니다

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
<span style="color: #ff00ff;"> xmlns:context="http://www.springframework.org/schema/context"  
</span>  
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
<span style="color: #ff00ff;">    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
</span>    "> 
 
  <!--  dao service ( ) --> 
  <context:component-scan base-package="com.makelove88.**.dao,com.makelove88.**.service" /> 
  <import resource="classpath*:*/applicationContext-*.xml" /> 
 
 
</beans> 

읽어주셔서 감사합니다. 여러분에게 도움이 되었으면 좋겠습니다. 본 사이트에 대한 지지에 감사드립니다!

좋은 웹페이지 즐겨찾기