我有一个Spring Boot Maven多模块项目,在该项目中,我try 在我的代码中使用Files.createDirecters方法创建一个目录.该项目的 struct 如下:
-GlobalProject :
CommonProject:
WebParentPrject:
backendPorject:
frontendProoject:
我想要在backendPorject目录中创建一个名为USER-IMAGE的目录.以下代码(在Backendproject中)在Eclipse中运行良好,但在IntelliJ中的行为不符合预期:
public class FileUploadUtil {
public static void saveFile(String uploadDir, String fileName, MultipartFile multipartFile) throws IOException {
Path uploadPath = Paths.get(uploadDir);
if(!Files.exists(uploadPath))
{
Path directories = Files.createDirectories(uploadPath);
System.out.println(directories);
}
try (InputStream inputStream = multipartFile.getInputStream()){
Path filePath = uploadPath.resolve(fileName);
Files.copy(inputStream,filePath, StandardCopyOption.REPLACE_EXISTING);
}catch (IOException exception){
throw new IOException("Could not save file : "+fileName,exception);
}
}
在Eclipse中,该目录是在BackendProject目录中创建的,但在IntelliJ中,该目录是在整个项目(MyProject)的根目录中创建的.我希望在两个IDE的BackendProject目录中创建该目录.
有没有人能帮我解释一下为什么在Eclipse和IntelliJ中行为不同,以及我如何修改代码以确保在两种IDE中的行为一致?