1 분 소요

lombok : setter, getter => annotation으로 해결

log4j : 로그 찍기.

hikaricp : connection pool

spring-tx : 트랜잭션 처리

mybatis : jsp에서 했던 처리(DAO로 DB 연결, preparedstatement, statement, 객체 연결,해제) 들을 쿼리로만 처리할 수 있다.

root-context.xml : 웹과 상관없는 db 설정(hikariConfig), root-context파일을 프로젝트가 알아서 인식을 하는 것이 아니라 web.xml에 설정을 해줘야 함. 만든 xml 파일을 spring에게 알려줘야한다.(<context-param>).

servlet-context.xml : 웹과 관련된 설정

  • mvc:annotation-driven : annotation 유도?
  • mvc:resources : 정적인 파일 위치 설정?

web.xml : 해당 프로젝트의 설정, 웹과 관련없는 코어에 관한 설정

디스패치 컨트롤러가 모든 요청을 받고 URL을 분석해서 컨트롤러를 선택함

페이지 흐름 : 컨트롤러

프로젝트 3티어 : web + service + persistence

service : 쇼핑몰에서 구매가 일어나면 재고 -1, 포인트 더해주느것과 같은 비즈니스 로직 구현

Gradle 프로젝트 만들 시 구성편집 => 배포 => war 지우고 exploded 추가해줘야 함. => 서버 => 클래스 및 리소스 업데이트 고치기

영속성 처리할 때 VO 사용. VO는 값을 읽는 역할만 함.

DTO는 계산을 할 때도 있다?

controller => service 전달 : DTO

service => mapper 전달 : VO

작성 순서

  1. build.gradle 설정

  2. root-context.xml, servlet-context.xml, web.xml

    • hikariConfig => DB 접근 설정

    • sqlSessionFactory => DB 처리 설정(sql로 바로 처리, DAO 역할)

      ** : 어떤 폴더든 상관없음(빈 폴더)
      <property name="mapperLocations" value="classpath:/mappers/**/*.xml"/>
      
  3. DTO, VO, Mapper

  4. TodoService

    • DTO, VO 매핑 => config/ModelMapperConfig
    • ModelMapperConfig : getConfiguration() : configuration을 얻음
    • setFieldMatchingEnabled : 필드 매칭을 하겠다
    • setMatchingStartegy : 매칭을 루즈하게
  5. Controller

댓글남기기