ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 03. Spring에서 MongoDB 사용하기
    Database/MongoDB 2016. 11. 21. 13:37
    반응형

    pom.xml


    mongo-java-driver 3.3.0버전


    spring-data-mongodb 추가하기





    spring 폴더에 mongoContext.xml 을 생성후



    을 작성해주면 기본 세팅은 1차 끝


    operationHistoryContext.xml


    <bean        id="operationLogHistoryDao"

    class="com.ktds.admin.operation.history.dao.impl.OperationHistoryDaoMongoDB">

    <property name="mongoTemplate" ref="mongoTemplate" />

    </bean>


    <bean id="operationHistoryBiz"


     


    <property name="operationLogHistoryDao" ref="operationLogHistoryDao" /> 추가하기


    OperationHistoryDaoImplOperationHistoryDaoOracle 로 이름변환


    OperationLogHistoryMongoDB를 밑에 처럼 작성




    OperationLogHistoryDao.java 인터페이스 생성


    public interface OperationLogHistoryDao extends OperationHistoryDao {

    public void writeLog(String logType, String message);

    }


    OperationHistoryBizImpl 에


    @Override

    public boolean addAllHistory(OperationHistoryVO operationHistoryVO) {


    operationLogHistoryDao.writeLog("OperationHistoryBizImpl.addAllHistory",

     "addAllHistory 호출");


    operationLogHistoryDao.writeLog("OperationHistoryBizImpl.addAllHistory", operationHistoryVO.getOperation() + "/" + operationHistoryVO.getOperationType());

    //추가하기


    return operationHistoryDao.addAllHistory(operationHistoryVO) > 0;

    }

    반응형

    'Database > MongoDB' 카테고리의 다른 글

    02. MongoDB Setting [ MongoDB ]  (0) 2016.11.21
    01. MongoDB 란? [ MongoDB ]  (0) 2016.11.16

    댓글

Designed by Tistory.