mybatisplus ssm配置要点

本以为不难,但也捣鼓了大半天,记录要点如下:

 

在pom中引入mybatis plus相关包

<!-- mybatis-plus框架包 start --> 
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus</artifactId>
            <version>${mybatis-plus.version}</version>
        </dependency>        
        
        <!-- freemarker --> 
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>${freemarker.version}</version>
        </dependency>
        <!-- freemarker end -->  
        
        <!-- lombok --> 
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
        <!-- mybatis-plus框架包 end -->    
        

引入后maven update,如果run有unzip错误那还是jar包下载出错,用maven install命令看具体哪个包有错误(maven test有时候看不出错误)

 

另外要注意spring与mybatis、mybatisplus的版本,好像某些版本存在不一致会报错sqlSessionFactory java.lang.reflect.MalformedParameterizedTypeException

<properties>    
        <jdk.version>1.8</jdk.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <srping.version>4.1.5.RELEASE</srping.version>    
        <mybatis.version>3.4.6</mybatis.version>    
        <mybatis-plus.version>2.3</mybatis-plus.version>
        <freemarker.version>2.3.28</freemarker.version>
        <lombok.version>1.16.20</lombok.version>
        <slf4j.version>1.7.12</slf4j.version>    
        <log4j.version>1.2.17</log4j.version>    
    </properties>  

 

lombok可以帮助省略掉实体类中的get set,但需要配置eclipse插件支持,否则敲.出不来get set,或能出来但是编译报错找不到get set

https://blog.csdn.net/houfeng30920/article/details/52312841

https://blog.csdn.net/dalinsi/article/details/78501027

https://www.cnblogs.com/hapday/p/6627703.html

 -Xbootclaspath/D:/copyright/repository/org/projectlombok/lombok/1.16.4/lombok-1.16.4.jar
 -javaagent:D:/copyright/repository/org/projectlombok/lombok/1.16.4/lombok-1.16.4.jar

 

 

然后将spring-mybatis-plus.xml 替换掉spring-mybatis.xml就可以用mybatisplus了。同时兼容mybatis原有的使用!

 

posted @ 2018-06-24 21:27  老豆芽  阅读(458)  评论(0编辑  收藏  举报