首页 > 其他分享 >Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(

Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(

时间:2024-06-03 21:35:19浏览次数:15  
标签:... use 启动 SpringBootConfiguration SpringBootTest need Unable test 如上图

问题描述:

在运行单元测试时报错

 

1. 没有启动类

 

2. 没有加载到启动类 -无法找到@SpringBootConfiguration

 

3. 测试类包名,调整到和启动类一致即可。

 

 

 

测试方法在运行的时候,需要寻找到SpringBoot启动类,默认情况下会直接在当前包路径上寻找,最简单的方法就是把你要测试的类和这个启动类放在一个包内。如上图。

 

还有就是当其不在一个包内时,在@SpringBootTest添加启动类,配置启动类,如上图。

 

标签:...,use,启动,SpringBootConfiguration,SpringBootTest,need,Unable,test,如上图
From: https://www.cnblogs.com/wjzohou/p/18229702

相关文章

  • Helm 图表在调用测试(test-connection.yml)时出现任何错误,如何在 NOTES.txt 中显示错误
    下面是我的test-connection.ymlapiVersion:v1kind:Pod元数据:name:"{{include"demohelmapi.fullname".}}-test-connection";labels:{{-include"demohelmapi.labels".|nindent4}}annotations:"helm.sh/hook&qu......
  • 谷歌浏览器Lighthouse网页性能分析工具使用
    需要使用谷歌浏览器的无痕模式要不然其他浏览器插件的脚本会影响页面的性能判断使用截图操作界面点击分析按钮开始分析生成分析建议部分:红色是有必要解决的性能提升建议红色建议分析:lighthouse文档文档地址:https://developer.chrome.com/docs/lighthouse/perf......
  • WPF canvas mousewheel to zoom in or out
    <Windowx:Class="WpfApp133.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft......
  • idea编辑器中 This document contents very long lines..........
    背景:在idea编辑器中引入压缩后的js文件在子目录中,有如下提示在控制台-元素中js并未加载上 另外,同文件夹下未压缩的js文件可正常加载。可以,排除,路径问题。 解决问题:压缩的js,得放到根目录,可能是文件太大了,需要预加载 ......
  • pytest运行报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in posit
    pytest运行报错:UnicodeDecodeError:‘gbk’codeccan’tdecodebyte0xafinposition82:illegalmultibytesequence  D:\Python\environment\python3.9.7\python3.exeD:/Python/nas_autotest/run.pyTraceback(mostrecentcalllast):File"D:\Python\......
  • 【安卓ROM包中Userdata.img 的组成部分和制作方法】
    userdata.img是Android设备上的一个重要分区映像文件,通常用于存储用户数据,包括用户安装的应用程序、应用数据、用户设置和其他用户生成的内容。这个分区是设备运行时动态变化的,因此创建和管理userdata.img的方式有所不同。下面是userdata.img的主要组成部分和制作方法的详......
  • AOP简化公共属性create_time,create_user,update_time,update_user记录的重复代码
    处理这些公共字段,需要在每一个业务方法中进行操作,编码相对冗余、繁琐使用AOP切面编程,实现功能增强,来完成公共字段自动填充功能。1.2实现思路在实现公共字段自动填充,也就是在插入或者更新的时候为指定字段赋予指定的值,使用它的好处就是可以统一对这些字段进行处理,避免了重......
  • Error creating bean with name 'userController': Unsatisfied dependency expressed
    SSM整合项目搭建时,项目启动报错,报错内容如下:org.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname'userController':Unsatisfieddependencyexpressedthroughfield'userService';nestedexceptionisorg.springfra......
  • 文献阅读——Single Clause Assumption without Activation Literals to Speed-up IC
    SingleClauseAssumptionwithoutActivationLiteralstoSpeed-upIC3 @inproceedings{DBLP:conf/fmcad/FroleyksB21,author={NilsFroleyksandArminBiere},title={SingleClauseAssumptionwithoutActivationLitera......
  • React(五)UseEffect、UseRef
    (一)useEffectuseEffect–React中文文档 useEffecthook用于模拟以前的class组件的生命周期,但比原本的生命周期有着更强大的功能1.类组件的生命周期在类组件编程时,网络请求,订阅等操作都是在生命周期中完成importReact,{Component}from'react'exportdefaultc......