码迷,mamicode.com
首页 > 其他好文 > 详细

记录一次@RunWith报错

时间:2019-04-08 15:20:28      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:put   fileinput   建议   pre   text   wired   tar   bind   分享图片   

 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报错

标签:put   fileinput   建议   pre   text   wired   tar   bind   分享图片   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!