运行springboot出现“A component required a bean of type...that could not be found“问题

 问题:

相关报错如下:

***************************
APPLICATION FAILED TO START
***************************

Description:

A ***ponent required a bean of type 'org.***.mapper.UserMapper' that could not be found.


Action:

Consider defining a bean of type 'org.***.mapper.UserMapper' in your configuration.

解决办法:

一:

查看导入的@Mapper是否正确

二:

 1.给主类XXXApplication加注解@MapperScan("包名.mapper文件夹名")

 2. pom.xml文件的build节点下加入如下代码:

 <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

转载请说明出处内容投诉
CSS教程_站长资源网 » 运行springboot出现“A component required a bean of type...that could not be found“问题

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买