zoukankan      html  css  js  c++  java
  • 记录一次@RunWith报错

     1)代码 这是一个文件上传的测试类 不重要,重要的是
    @RunWith(SpringRunner.class)报错!
    
    
    import com.github.tobato.fastdfs.domain.StorePath;
    import com.github.tobato.fastdfs.domain.ThumbImageConfig;
    import com.github.tobato.fastdfs.service.FastFileStorageClient;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;

    @RunWith(SpringRunner.class)
    @SpringBootTest
    public class FdfsTest {

    @Autowired
    private FastFileStorageClient storageClient;

    @Autowired
    private ThumbImageConfig thumbImageConfig;

    @Test
    public void testUpload() throws FileNotFoundException {
    File file = new File("D:\壁纸\白色毛衣 牛仔长裤子 4k美女壁纸_彼岸图网.jpg");
    // 上传
    StorePath storePath = this.storageClient.uploadFile(
    new FileInputStream(file), file.length(), "jpg", null);
    // 带分组的路径
    System.out.println(storePath.getFullPath());
    // 不带分组的路径
    System.out.println(storePath.getPath());
    }
    }
    2)pom.xml文件
    spring-boot-starter-test依赖中已经集成了junit4.12
    技术分享图片
    <dependencies>
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
    <groupId>com.github.tobato</groupId>
    <artifactId>fastdfs-client</artifactId>
    </dependency>

    </dependencies>
    3)解决
    1)找到本地maven仓库删库就行了Ctrl+a 删除就行了
    技术分享图片

    2)不建议用阿里或者别的私服,直接中央仓库下载就行了!以为我就是用阿里下载的依赖库

    3)下载完后重构一下maven索引

    技术分享图片

    4)然后你就会发现你所有maven依赖都会报错,接下来就要剪切掉<dependencies>标签内的所有依赖坐标!然后就会出现下图的 Import change  点击 
    技术分享图片

    5)然后在粘贴回来  点击 Import change  OK!!

    技术分享图片

    岁月无声无息的溜走,除了带走一个无聊者的时光,还会沉淀一个努力者的人生。
  • 相关阅读:
    云栖大会|盛宴之下,共赴一场视频云的进化论
    云栖大会|感受万物数字化,体验千行视频化
    浅谈语音质量保障:如何测试 RTC 中的音频质量?
    一朵云、一张网、一体化 ——GRTN 打造最佳流媒体场景实践
    穿越时空,跟我一起探索云栖数字谷(2021云栖大会免费送票)
    如何实现 iOS 短视频跨页面的无痕续播?
    如何实现 Android 短视频跨页面的流畅续播?
    揭秘盒马鲜生 Android 短视频秒播优化方案
    SQLServer2012SP1-FullSlipstream-CHS-x64标准版.iso
    mes系统是做什么的?MES是什么全称是什么?
  • 原文地址:https://www.cnblogs.com/dayandday/p/10670445.html
Copyright © 2011-2022 走看看