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!!

    技术分享图片

    岁月无声无息的溜走,除了带走一个无聊者的时光,还会沉淀一个努力者的人生。
  • 相关阅读:
    中高级PHP程序员应该掌握哪些技术
    如何在FOXMAIL添加网易邮箱
    subline text 3快捷键
    【sublime】sublime Text 3 javaScript代码自动提示插件&安装步骤 &启动Debug模式
    PHPStorm常用快捷键
    怎么样快速修改HOSTS文件?让火绒等小工具来帮忙
    windows系统 右键新建菜单添加新建php文件
    给初学编程的人的干货
    安装Adobe Dreamweaver CC时出现安装失败及解决方法
    win10系统每次打开软件都会弹出账户控制如何解决
  • 原文地址:https://www.cnblogs.com/dayandday/p/10670445.html
Copyright © 2011-2022 走看看