springboot 报错 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' available: 有没有大佬出个主意,我找了一天,刚入门springboot

话不多说先上图,这是启动类的配置,这里配置了@ComponentScan("我的mapper的接口")

接下来是我的项目结构截图

然后是service 的截图,我在这里加了注解@Service

最后我在测试类里面 的截图

最后附上我的maven的pom 我开始怀疑是这个配置的有问题了

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <parent>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-parent</artifactId>        <version>2.2.2.RELEASE</version>        <relativePath/> <!-- lookup parent from repository -->    </parent>    <groupId>com.example</groupId>    <artifactId>demo</artifactId>    <version>0.0.1-SNAPSHOT</version>    <name>demo</name>    <description>Demo project for Spring Boot</description>

    <properties>        <java.version>1.8</java.version>    </properties>

    <dependencies>        <dependency>            <groupId>org.projectlombok</groupId>            <artifactId>lombok</artifactId>            <version>1.16.10</version>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-cache</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-data-redis</artifactId>            <exclusions>                <exclusion>                    <groupId>io.lettuce</groupId>                    <artifactId>lettuce-core</artifactId>                </exclusion>            </exclusions>        </dependency>        <dependency>            <groupId>redis.clients</groupId>            <artifactId>jedis</artifactId>        </dependency>        <dependency>            <groupId>com.alibaba</groupId>            <artifactId>druid</artifactId>            <version>1.1.10</version>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-security</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>        <dependency>            <groupId>org.mybatis.spring.boot</groupId>            <artifactId>mybatis-spring-boot-starter</artifactId>            <version>2.1.1</version>        </dependency>

        <dependency>            <groupId>mysql</groupId>            <artifactId>mysql-connector-java</artifactId>            <scope>runtime</scope>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-test</artifactId>            <scope>test</scope>            <exclusions>                <exclusion>                    <groupId>org.junit.vintage</groupId>                    <artifactId>junit-vintage-engine</artifactId>                </exclusion>            </exclusions>        </dependency>        <dependency>            <groupId>io.projectreactor</groupId>            <artifactId>reactor-test</artifactId>            <scope>test</scope>        </dependency>        <dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <scope>test</scope>        </dependency>    </dependencies>

    <build>        <plugins>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>            </plugin>        </plugins>        <resources>            <resource>                <directory>src/main/java</directory>                <includes>                    <include>**/*.xml</include>                </includes>            </resource>            <resource>                <directory>src/main/resources</directory>            </resource>        </resources>    </build>

</project>

详细的报错信息如下:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.example.service.HrService‘ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1695) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1253) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]

springboot 报错 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' available: 有没有大佬出个主意,我找了一天,刚入门springboot

原文地址:https://www.cnblogs.com/naotaitao/p/12106213.html

时间: 2024-11-08 14:07:05

springboot 报错 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' available: 有没有大佬出个主意,我找了一天,刚入门springboot的相关文章

添加事务后 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type available

今天遇到了一个奇怪的问题   在没添加事务之前  所有的代码都是好的 , 当我添加了事务之后, 代码报错 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type available ApplicationContext: <!-- 配置事务 --> <bean id="transactionManager" class="org.s

spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type &#39;com.self.spring.springboot.Jeep&#39; available

我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available at org.springframework.beans.factory.sup

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency

在整合ssm框架,测试service层的时候报错 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [dx.service.ItemService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dep

org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type &#39;xxx &#39;available

搭了一个简单的SSM项目,启动报错: org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.xxx.ssmdemo.service.IUserService' available: expected at least 1 bean which qualifies as autowire candidate.Dependency annotations: {@o

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

问题描述 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'xxxxx.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factor

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut

spring中一个符号的错误居然让我浪费了四五个小时才找出来,不得不给自己了两个耳光.. 由于新建项目与原来项目的目录结构有所不同,copy过来的配置文件,有些地方修改的不彻底,导致spring扫描注解的时候,扫描不到,不能注入bean,导致运行出错.一个马虎浪费了这么多时间,符号这种问题也往往最容易忽视的.<context:component-scan base-package="com.oskyhang.*.service"/> <context:componen

SSM整合报错org.springframework.beans.factory.UnsatisfiedDependencyException

我解决的办法是把.m2仓库所有文件删除,重新maven project就可以了. 但是在做这一步之前,报错如下: ①org.springframework.beans.factory.UnsatisfiedDependencyException ②ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Sta

spring报错 org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [cn/itcast/b_anno/bean.xml]; nested exception is java.lang.

这次遇到的错是在 使用注解的方式 来使用事务的时候 在配置文件中配置了 但是却没有使用 补充:没有aop相关的包也会报这个错,需要加上aop的包 解决:在配置文件中将事务有关的配置移除了然后就好了          额,看来在配置文件中的东西一定注意啊,需要使用的时候才去进行配置,不要多配置也不要少配置

出现org.springframework.beans.factory.NoSuchBeanDefinitionException 的解决思路

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.itcast.crm.service.BaseDictService cn.itcast.crm.controller.CustomerController.baseDictService; nested exception is org.springframework.beans.fac