jayo
427
2018-03-14 16:26:07
0
565

몽고DB 스프링에서 사용하는법 질문좀 드릴게요 ㅜ.ㅜ..


본래 하던게 오라클과 mysql DB를 사용했는데. 이번에 스프링에 몽고DB로 만들게 되었습니다.

몽고DB는 완전 생초보라.. 감이 잘안잡혀서, 일단 인터넷보면서 이것저것 해보고있는데요.

일단. 게시판에 글이라도 띄어봐야지.. 하고있는데. 초장 DB 연동부터 막히는것 같습니다.

mongoContext.xml에 새로 넣고 하는방식으로 알고있는데..

 <mongo:mongo-client
        host="localhost"
        port="27017"
        credentials="sys:1234@admin"> 
        <mongo:client-options
            connections-per-host="8"
            threads-allowed-to-block-for-connection-multiplier="32"
            connect-timeout="1000000"
            max-wait-time="1500000"
            socket-keep-alive="true"
            socket-timeout="1500000" />

</mongo:mongo-client>

이게 DB연동하는걸로 알고있어서. 연동하고 .. dao 만들고,  insert와 find 할 수 있는 구문만 넣고

값이 나오는지 확인하기위해서 main이라는 클래스를 만들어서

public static void main(String [] args){
  String url = "mongoContext.xml";
  GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(url);
  
  MongoDAO dao = ctx.getBean("mongoDAO", MongoDAO.class);
  if(dao == null){
   System.out.println("값이 존재하지않습니다.");
  }else {
   System.out.println("값을 확인하였습니다.");


이런식으로 값 있나 없나부터 확인하려고했는데 .. 오류가 떠버립니다 .. ㅜ.ㅜ

오류내용은

---------------------------------------

INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [mongoContext.xml]
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 32 in XML document from class path resource [mongoContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 68; cvc-complex-type.2.4.a: 'constuructor-arg' 요소로 시작하는 부적합한 콘텐츠가 발견되었습니다. '{"http://www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":meta, "http://www.springframework.org/schema/beans":constructor-arg, "http://www.springframework.org/schema/beans":property, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method, WC[##other:"http://www.springframework.org/schema/beans"]}' 중 하나가 필요합니다.
 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.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
 at org.springframework.context.support.GenericXmlApplicationContext.load(GenericXmlApplicationContext.java:117)
 at org.springframework.context.support.GenericXmlApplicationContext.<init>(GenericXmlApplicationContext.java:70)
 at com.young.test.Main.main(Main.java:14)
Caused by: org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 68; cvc-complex-type.2.4.a: 'constuructor-arg' 요소로 시작하는 부적합한 콘텐츠가 발견되었습니다. '{"http://www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":meta, "http://www.springframework.org/schema/beans":constructor-arg, "http://www.springframework.org/schema/beans":property, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method, WC[##other:"http://www.springframework.org/schema/beans"]}' 중 하나가 필요합니다.
 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
 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)
 ... 9 more
----------------------------------------------------

이런 오류인데 뭘 잘못할걸까요? ㅜ.ㅜ;; 아무리찾아봐도 감이안잡혀서 글적게되었습니다.. ㄷ

시작부터 클났네요.. ㅠ 잘부탁드립니다..!




0
0
  • 답변 0

  • 로그인을 하시면 답변을 등록할 수 있습니다.