记录一次@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!!
岁月无声无息的溜走,除了带走一个无聊者的时光,还会沉淀一个努力者的人生。