-
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" /> 추가하기
OperationHistoryDaoImpl을 OperationHistoryDaoOracle 로 이름변환
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