Using maven recently, it's driving people crazy. The reason is missing artifact xxxx failed to transfer xxxx. These problems are complicated and difficult to deal with. Most of the final reason is that the network fails when downloading the jar package, and the downloaded jar package ends with lastUpdated, resulting in the complete jar package not being downloaded. At this time, if you check one by one according to the pom.xml file, wait for you to check. It's over, the girls are all married. Of course, being a programmer is lazy. It is easy to write a piece of code, and my mother will no longer worry about my pom.xml file reporting an error.
package com.java8.test;
import java.io.File;
public class DelFileEndWithLasted {
public static void main(String[] args) {
File file = new File("E:/RepositoryMars");
// System.out.println (file.isDirectory());
//Recursive method
deleteFile(file);
}
//Delete the lastUpdated file under the repository to solve the problem of pom.xml file error
public static void deleteFile(File file){
if(file.isDirectory()){
//If it is a directory, traverse the following files
File[] files = file.listFiles();
for (File file2 : files) {
deleteFile(file2);
}
}else{
//If it is not a directory, judge whether the file ends with lastUpdated, and delete the file
if(file.getName().endsWith(".lastUpdated")){
// file.delete();
System.out.println(file. getName());
}
}
}
}