首页 > 其他 > 详细

记录一次@RunWith报错

时间:2019-04-08 15:15:51      阅读:131      评论:0      收藏:0      [点我收藏+]
 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!!

技术分享图片

记录一次@RunWith报错

原文:https://www.cnblogs.com/dayandday/p/10670445.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!