springboot出错“Error creating bean with name”和“Loading class `com.mysql.jdbc.Driver‘”的解决办法

记录一下使用springBoot的时候出现的错误:
第一个错误:Error creating bean with name ‘userMapper’
出错的原因就是说检查依赖的正确性: 确保’userMapper’的实现类(例如’UserMapper’)已经正确定义,并且在配置文件中将其与相应的bean关联起来。还要确保依赖的类路径正确,且所有相关的库和依赖项已正确引入项目。
但是我后来发现是我用的依赖的版本过低导致的,我换了一个高点的就解决了这个问题,xml里面添加的依赖如下:

<dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter-test</artifactId>
            <version>3.0.1</version>
            <scope>test</scope>
        </dependency>

第二个错误:Loading class `com.mysql.jdbc.Driver’. This is deprecated.
简单来说就是现在这个依赖的语法不这样写啦,于是我又在application中将写法改成了“com.mysql.cj.jdbc.Driver”,这样问题就解决了。

总结:第一,善于使用百度翻译;第二,一定要细心一点,其实springboot还是很智能的。

猜你喜欢

转载自blog.csdn.net/weixin_43148375/article/details/131728629