티스토리 뷰

>> 사용할 DB 및 계정 생성

create tablespace EGOV_ENTR 

datafile 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\EGOV_ENTR.DBF' 

size 10M 

autoextend on next 5M;

 

create user egoventr identified by egoventr

default tablespace EGOV_ENTR

quota unlimited on EGOV_ENTR

temporary tablespace TEMP;

 

GRANT CONNECT, RESOURCE, CREATE VIEW TO egoventr;


>> 테이블 및 기초데이타 생성

DATABASE\all_ebt_ddl_oracle.sql

DATABASE\all_ebt_data_oracle.sql


>> DB 종류, DB계정, DB연결URL 설정

    src\main\resources\egovframework\egovProps\globals.properties

   

>> 사용할 DB의 datasource 설정

src\main\resources\egovframework\spring\com\context-datasource.xml

>> 사용할 DB에 맞는 dependency설정

pom.xml


>> 추가 Datasource 설정: 프레임워크 DB와 업무DB를 분리할 경우. 업무용 DB datasource 추가설정.

> globals.properties 에 datasource 파라미터 추가

예)

# biz datasource

datasource.sample.DriverClassName=oracle.jdbc.driver.OracleDriver

datasource.sample.Url=jdbc:oracle:thin:@127.0.0.1:1521:xe

datasource.sample.UserName=hr

datasource.sample.Password=hr1q2w

> context-datasource.xml 에 datasource bean 추기

예)

<!-- sample datasource -->

      <bean id="dataSource-sample" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

         <property name="driverClassName" value="${datasource.sample.DriverClassName}"/>

         <property name="url" value="${datasource.sample.Url}" />

         <property name="username" value="${datasource.sample.UserName}"/>

         <property name="password" value="${datasource.sample.Password}"/>

     </bean>


>> MyBatis 설정

> mapper 디렉토리 생성 : src\main\resources\egovframework\mapper

> mapper config xml 생성 : 예) src\main\resources\egovframework\mapper\sql-mapper-config-sample.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">


<configuration>

    <typeAliases>

<typeAlias alias="egovMap" type="egovframework.rte.psl.dataaccess.util.EgovMap"/>

    </typeAliases>

</configuration>


> mybatis sqlSession bean 정의 context xml 추가 : src\main\resources\egovframework\spring\com\context-mapper.xml

<?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-4.0.xsd">


<bean id="sqlSessionSample" class="org.mybatis.spring.SqlSessionFactoryBean">

<property name="dataSource" ref="dataSource-sample" />

<property name="configLocation" value="classpath:/egovframework/mapper/sql-mapper-config-sample.xml" />

<property name="mapperLocations" value="classpath:/egovframework/mapper/**/*.xml" />

</bean>


  <bean class="sample.common.SampleMapperConfigurer">

<property name="basePackage" value="sample" />

</bean>

</beans>


> 사용자정의 MapperScannerConfigurer 클래스 추가

public class SampleMapperConfigurer extends MapperScannerConfigurer {

/**

* 기본 정보(anntationClass, sqlSessionFactoryBeanName)으로 설정한다.

*/

public SampleMapperConfigurer() {

super.setAnnotationClass(Mapper.class);

super.setSqlSessionFactoryBeanName("sqlSessionSample");

}

}

* 위와 같이 별도의 mapper scanner 클래스 생성없이 아래와 같이 bean 설정해도 됨.

       <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<property name="basePackage" value="sample" />

<property name="annotationClass" value="egovframework.rte.psl.dataaccess.mapper.Mapper" />

<property name="sqlSessionFactoryBeanName" value="sqlSessionSample" />

</bean>


> context-transaction 추가설정: annotaion transaction설정

<!-- transaction 추가 -->

<bean id="txManagerSample" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource" ref="dataSource-sample"/>

 </bean>

    

 <tx:annotation-driven transaction-manager="txManagerSample"/>


>> 업무영역 소스 패키지에 대한 component스캔 추가 : context-common.xml, base-package 옵션에 , 구분된 패키지명 추가.

src\main\resources\egovframework\spring\com\context-common.xml     

src\main\webapp\WEB-INF\config\egovframework\springmvc\egov-com-servlet.xml


        <!-- component-scan 설정-->

<context:component-scan base-package="egovframework,sample">

<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>

<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>

<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>

</context:component-scan>


>>엔터프라이즈 포탈 메인 페이지 : http://localhost:8080/ebt_webapp/uat/uia/actionMain.do


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28