springboot+mybatis-plus启动项目提示找不到MybatisAutoConfiguration

springboot+mybatis-plus启动项目提示找不到MybatisAutoConfiguration

控制台日志摘录

2020-06-02 15:03:23.339 |-ERROR [main] org.springframework.boot.SpringApplication [837] -| Application run failed
java.lang.IllegalArgumentException: Could not find class [org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration]
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:335)
	at org.springframework.core.annotation.TypeMappedAnnotation.adapt(TypeMappedAnnotation.java:446)
	at org.springframework.core.annotation.TypeMappedAnnotation.getValue(TypeMappedAnnotation.java:369)
	at org.springframework.core.annotation.TypeMappedAnnotation.asMap(TypeMappedAnnotation.java:284)
	at org.springframework.core.annotation.AbstractMergedAnnotation.asAnnotationAttributes(AbstractMergedAnnotation.java:193)
	at org.springframework.core.type.AnnotatedTypeMetadata.getAnnotationAttributes(AnnotatedTypeMetadata.java:106)
	at org.springframework.context.annotation.AnnotationConfigUtils.attributesFor(AnnotationConfigUtils.java:285)
	at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:102)
	at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:81)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.registerBeanDefinitionForImportedConfigurationClass(ConfigurationClassBeanDefinitionReader.java:160)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at com.yuantiaokj.merchant_web.MerchantWebApplication.main(MerchantWebApplication.java:26)
Caused by: java.lang.ClassNotFoundException: org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at org.springframework.util.ClassUtils.forName(ClassUtils.java:285)
	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:325)
	... 25 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:60533', transport: 'socket'

项目结构为springboot多模块项目,项目配置是从我之前的一个单模块项目拷贝过来的,之前的那个项目也是springboot + mybatis-plus 项目,项目正常启动,但是挪过来之后项目起不来了,对比了之前的配置和依赖管理,也没有问题,整这个问题也整了一大早,之前用过所以也知道mybatis-plus和mybatis-spring 是冲突的,所以肯定不是这两个jar包里面的问题,有的博客说把配置yml里面 的mybatis-plus: 换成mybatis: ,我想着那不就是不用mybatis-plus 直接用mybatis了吗.找了好久都找不到 ,干脆直接在maven仓库里面找到这个依赖引进来试一下,结果项目启动报错变了,然后修改了一下配置文件 成功启动了.实在是想不明白为什么之前项目里面不引入一切正常,现在这个项目就必须引入才能正常启动,

贴出这个maven坐标

        <dependency>
            <groupId>org.mybatis.spring.bootgroupId>
            <artifactId>mybatis-spring-boot-autoconfigureartifactId>
            <version>2.1.1version>
        dependency>

把我整个mybatis-plus 的maven坐标贴出来

        
        <dependency>
            <groupId>com.baomidougroupId>
            <artifactId>mybatis-plus-boot-starterartifactId>
        dependency>
        <dependency>
            <groupId>com.baomidougroupId>
            <artifactId>mybatis-plus-generatorartifactId>
            <exclusions>
                <exclusion>
                    <artifactId>jsqlparserartifactId>
                    <groupId>com.github.jsqlparsergroupId>
                exclusion>
                <exclusion>
                    <artifactId>mybatis-plus-extensionartifactId>
                    <groupId>com.baomidougroupId>
                exclusion>
            exclusions>
        dependency>
        <dependency>
            <groupId>org.mybatis.spring.bootgroupId>
            <artifactId>mybatis-spring-boot-autoconfigureartifactId>
            <version>2.1.1version>
        dependency>
        <dependency>
            <groupId>org.freemarkergroupId>
            <artifactId>freemarkerartifactId>
        dependency>

        

最后还得说一句 引了mybatis-plus 就不要引入mybatis 不然肯定会冲突项目起不来的,除非自己排掉冲突依赖

你可能感兴趣的:(springboot)