【Mybatis】Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin

问题描述

利用 mybatis-generator-core 生成数据表对应实体类、mapper(dao)接口类和mapper.xml(sql配置文件),在pom.xml中进行如下配置



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.2.4.RELEASE
         
    

    com.example
    sb-crmdsz
    0.0.1-SNAPSHOT
    sb-crmdsz
    Demo project for Spring Boot

    
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.mybatis.generator
            mybatis-generator-core
            1.4.1
        

        
            mysql
            mysql-connector-java
            8.0.18
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            

            
                org.mybatis.generator
                mybatis-generator-maven-plugin
                1.4.1
                
                    ${basedir}/src/main/resources/generator/generatorConfig.xml
                    true
                    true
                
            
        
    

    
        
            nexus-aliyun
            aliyun nexus
            https://maven.aliyun.com/repository/public/
            
                true
            
            
                false
            
        
    

    
        
            nexus-aliyun
            aliyun nexus
            https://maven.aliyun.com/repository/public/
            
                true
            
            
                false
            
        
    


执行命令

【Mybatis】Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin_第1张图片

报错

Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.4.1:generate (default-cli) on project sb-crmdsz: Execution default-cli of goal org.mybatis.generator:mybatis-generator-maven-plugin:1.4.1:generate failed: Exception getting JDBC Driver

原因分析

问题解决

在插件中再次引入mysql驱动依赖

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            

            
                org.mybatis.generator
                mybatis-generator-maven-plugin
                1.4.1
                
                    ${basedir}/src/main/resources/generator/generatorConfig.xml
                    true
                    true
                
                
                    
                        mysql
                        mysql-connector-java
                        8.0.18
                    
                
            
        
    

参考文章

https://blog.csdn.net/qq_40996741/article/details/113960723

你可能感兴趣的:(mybatis,maven,java)