TestRestTemplate注入时异常NoSuchBeanDefinitionException
来源:互联网 发布:渗透结晶防水涂料与js 编辑:程序博客网 时间:2024/06/05 19:00
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.ums.biz.user.service.UserServiceTest': Unsatisfied dependency expressed through field 'testRestTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.test.web.client.TestRestTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
解决方式如下:
将头部的注解修改
@RunWith(SpringRunner.class)
@SpringBootTest
改为:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
即可解决
阅读全文
0 0
- TestRestTemplate注入时异常NoSuchBeanDefinitionException
- nosuchbeandefinitionexception 注入失败
- factory.NoSuchBeanDefinitionException 异常
- NoSuchBeanDefinitionException
- NoSuchBeanDefinitionException
- NoSuchBeanDefinitionException
- 异常org.springframework.beans.factory.NoSuchBeanDefinitionException
- org.springframework.beans.factory.NoSuchBeanDefinitionException: 异常处理
- spring异常org.springframework.beans.factory.NoSuchBeanDefinitionException
- Bean对象注入失败 .NoSuchBeanDefinitionException: No qualifying bean of type..
- SpringMvc常见异常之org.springframework.beans.factory.NoSuchBeanDefinitionException
- mybatis整合ss的时候,无法autowire使用mapper的自动注入,找不到bean:NoSuchBeanDefinitionException
- SpringBoot Mybatis注入异常
- spring bean注入异常
- 关于maven项目tomcat启动异常org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 解决
- spring NoSuchBeanDefinitionException
- 谈谈 NoSuchBeanDefinitionException
- Spring NoSuchBeanDefinitionException
- 将数据流转化为图片 并显示在前台页面
- 了解BFF架构
- 【Q&A】tomcat启动报错org/jersey/com/google/common/base/Function
- 鼠标滚轮怎么变调节音量了
- 代码中动态设置权重
- TestRestTemplate注入时异常NoSuchBeanDefinitionException
- Java NIO原理图文分析及代码实现
- SparkStreaming数据源之Kafka
- 【工具使用】eclipse打war包
- Android 手机设备信息获取使用详解
- Android用ContextCompat替换getResources()获取资源
- MySQL数据库从下载到启动详解--连咸鱼都能学会
- Java生成验证码并进行验证
- macOS 10.11.6 (或更低版本)直接升级至macOS Sierra 10.12.6版本