IT'S DO
728x90

사용 할때
# Mapper.xml
이 MainMapper.xml을 src>main>webapp>resources>mappers>MainMapper.xml을 만들어줌.

그리고 MainMapper.xml안에
<mapper namespace="com.test.cds.MainMapper">
로 프로젝트 root 경로에 맞게끔 이름 지정 잘해줘서 사용해야함. 이렇게 해야지 맵핑이 됨.

# root-context.xml
root-context.xml에서

   <!-- MyBatis-Spring -->
   <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
   <property name="dataSource" ref="dataSource" />
   <!-- ibatis와 다르게 sql디렉토리에 xml 추가만 해주면 별도추가없이 알아서 xml내의 쿼리 인식 -->
   <property name="mapperLocations">
      <list> <!-- 해당 경로를 통해 xml을 읽어옵니다. -->
         <value>/resources/mappers/*.xml</value>
      </list>
   </property>
   <property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean>



# mybatis-config.xml
mybatis-config.xml에서
=> classpath:mybatis-config.xml 이라고 하면 보통
=> main>resources>mybatis-config.xml 위치
에 해당 파일을 열어서

<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>

<typeAliases>
<typeAlias type="com.test.cdc.test.VO.TestVO" alias="TestVO"/>
<typeAlias type="com.hm.sds.exe.VO.ExeVO" alias="ExeVO"/>
</typeAliases>
</configuration>

같이 맞춰주기

profile

IT'S DO

@멋진놈

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!