steammend 마지막 pj에서 사용한 mybatis 잊을까봐 관련해 재공부 목적
진행에 앞서 MyBatis 구현과 관련해 추가적인 정보를 말하자면
steammend에서 controller, class
<=> Service, interface
<=> ServiceImpl, class(Service 상속)
<=> mapper, interface
구조로 진행했는데 사실 mapper
가 존재하는 상황에서 interface(service
)가 추가로 존재할 필요는 없다고 생각하며 존재해도 service
가 아니라 serviceImpl
가 interface 형태로 존재했어야 된다 생각한다
.xml
file에 sql 쿼리로 등록Controller
<=> Service
<=> Mapper
<=> DB
로 운영.xml
file들 위치.xml
file에 sql query를 기입namespace
: mapper(interface)에 위치id
: mapper에 해당 메서드명parameterType
, returnType
: 입력, 출력 타입을 지정
.xml
file들 존재하기에 경로 지정mybatis.mapper-locations: mappers/*.xml
mybatis.type-aliases-package=com.example.demo.model.domain
mybatis.configuration.map-underscore-to-camel-case=true
@autowired
를 정의해주지 않아서 발생하는 문제였다