weixin_42768559
月落乀最红尘
采纳率0%
2018-11-30 03:08

mybatisplus自动生成的代码为什么导入的包路径错误?

第一次使用Mybatis-plus,在做完配置之后,点击mp:code,生成的代码如下:

很多文件中都是包的路径错误,这是什么情况啊,。。。。应该怎么解决呢???
这里是包的路径import com.baomidou.mybatisplus.annotation.TableId;
生成的是import com.baomidou.mybatisplus.annotations.TableId;
图片说明

这里路径应该为import com.baomidou.mybatisplus.extension.service.IService;
结果生成了import com.baomidou.framework.service.IService;
图片说明

配置文件如下:
pom.xml

 <?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.wuyunfeng</groupId>
    <artifactId>TestPlus</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>TestPlus Maven Webapp</name>
    <url>http://www.wuyunfeng.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <!--  spring版本号  -->
        <spring.version>4.3.5.RELEASE</spring.version>
        <!--  mybatis版本号  -->
        <mybatis.version>3.4.1</mybatis.version>
        <!--  log4j日志文件管理包版本  -->
        <slf4j.version>1.7.12</slf4j.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

    <dependencies>
        <!-- 单元测试 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <!-- 表示开发的时候引入,发布的时候不会加载此包 -->
            <scope>test</scope>
        </dependency>
        <!-- java ee包 -->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
        </dependency>
        <!-- 导入mybatis-plus包 start -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus</artifactId>
            <version>3.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.7</version>
        </dependency>
        <!-- 导入mybatis-plus包 end -->
        <!-- 数据库驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.41</version>
        </dependency>
        <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 -->
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <!-- jstl标签类 -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <!-- log start -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <!-- log END -->
        <!-- 格式化对象,方便输出日志 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.6</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>
        <!-- 上传组件包 start -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>
        <!-- 上传组件包 end -->
        <!-- AL相关添加 -->
        <dependency>
            <groupId>net.sourceforge.jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.8</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.9</version>
        </dependency>
        <!-- AL相关添加 -->
        <!-- https://mvnrepository.com/artifact/net.sourceforge.javacsv/javacsv -->
        <dependency>
            <groupId>net.sourceforge.javacsv</groupId>
            <artifactId>javacsv</artifactId>
            <version>2.0</version>
        </dependency>
        <!-- spring框架包 start -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- spring框架包 end -->

        <!-- spring 新添加的可选包 项目中未用到-->
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${spring.version}</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.version}</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>${spring.version}</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>TestPlus</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatisplus-maven-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <!-- 输出目录(默认java.io.tmpdir) -->
                    <outputDir>/run/media/ry03/wuyunfeng/workspace/IDEA/TestPlus/src/main/java</outputDir>
                    <!-- 是否覆盖同名文件(默认false) -->
                    <fileOverride>true</fileOverride>
                    <!-- mapper.xml 中添加二级缓存配置(默认true) -->
                    <enableCache>false</enableCache>
                    <!-- 开发者名称 -->
                    <author>WuYunfeng</author>
                    <!-- 是否开启 ActiveRecord 模式(默认true) -->
                    <activeRecord>false</activeRecord>
                    <!-- 数据源配置,( **必配** ) -->
                    <dataSource>
                        <driverName>com.mysql.jdbc.Driver</driverName>
                        <url>jdbc:mysql://127.0.0.1:3306/testssm?useUnicode=true&amp;useSSL=false&amp;characterEncoding=utf-8</url>
                        <username>root</username>
                        <password>123456</password>
                    </dataSource>
                    <strategy>
                        <!-- 字段生成策略,四种类型,从名称就能看出来含义:
                            nochange(默认),
                            underline_to_camel,(下划线转驼峰)
                            remove_prefix,(去除第一个下划线的前部分,后面保持不变)
                            remove_prefix_and_camel(去除第一个下划线的前部分,后面转驼峰) -->
                        <naming>underline_to_camel</naming>

                        <!-- 表前缀 -->
                        <tablePrefix>bmd_</tablePrefix>

                        <!--Entity中的ID生成策略(默认 id_worker)-->
                        <idGenType>auto</idGenType>

                        <!--自定义超类-->
                        <!--<superServiceClass>com.baomidou.base.BaseService</superServiceClass>-->

                        <!-- 要包含的表 与exclude 二选一配置-->
                        <include>
                            <property>user</property>
                            <!--<property>message</property>-->
                        </include>

                        <!-- 要排除的表 -->
                        <!--<exclude>-->
                            <!--<property>schema_version</property>-->
                        <!--</exclude>-->
                    </strategy>
                    <packageInfo>
                        <!-- 父级包名称,如果不写,下面的service等就需要写全包名(默认com.baomidou) -->
                        <parent>com.wuyunfeng</parent>
                        <!-- service包名(默认service) -->
                        <service>service</service>
                        <!-- serviceImpl包名(默认service.impl) -->
                        <serviceImpl>service.impl</serviceImpl>
                        <!-- entity包名(默认entity) -->
                        <entity>model</entity>
                        <!-- mapper包名(默认mapper) -->
                        <mapper>mapper</mapper>
                        <!-- xml包名(默认mapper.xml) -->
                        <xml>mapper.xml</xml>
                        <!-- controller包名(默认controller) -->
                        <controller>controller</controller>
                    </packageInfo>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.41</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • qq_31122833 小达哥的垃圾桶 3年前

    你是不是依赖错了

     <dependency>
              <groupId>com.baomidou</groupId>
               <artifactId>mybatis-plus</artifactId>
                <version>2.1.9</version>
     </dependency>
    

    或者多个mybatis-plus的依赖啊?去掉多余的
    图片说明
    pom依赖:

     <dependency> 
         <groupId>com.baomidou</groupId> 
         <artifactId>mybatisplus-spring-boot-starter</artifactId>
         <version>1.0.5</version>
    </dependency>
    <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus</artifactId>
                <version>2.1.9</version>
    </dependency>
    
    点赞 1 评论 复制链接分享

相关推荐