2015年10月8日 星期四

spring4 + mybatis3 sample (簡易版) - mybatis annotation

因為現在 annotation 很紅~
所以就試了一下~真的超簡短~~~
不過重點在於前面的設定要搞好....

複習 在 spring bean 要設定:
<bean id="myBatisMapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       <property name="basePackage" value="xxx.xxx.xxx.xxx"/>
       <property name="annotationClass" value="org.springframework.stereotype.Repository"/>
    </bean>

SampleDao

import java.util.*;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Repository
public interface SampleDao {
   
    @Select("SELECT * FROM aa")
    public List<HashMap> selectSample();
}

沒有留言: