[fix]docker运行报错问题

This commit is contained in:
枫落时 2024-11-21 13:10:58 +08:00
parent a824cdc497
commit 02dcc8d7f4

View File

@ -8,7 +8,7 @@ import org.springframework.boot.system.ApplicationHome;
import org.springframework.core.io.ClassPathResource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
public interface FileTools {
@ -30,14 +30,14 @@ public interface FileTools {
File file = getFile(path);
if (ObjectUtil.isNotNull(application.getSource())) {
ClassPathResource classPathResource = new ClassPathResource(path);
File classPathFile = FileUtil.file(classPathResource.getPath());
if (classPathResource.exists() && !file.exists()) {
try {
FileUtil.writeFromStream(classPathResource.getInputStream(), classPathFile);
try (InputStream inputStream = classPathResource.getInputStream()) {
FileUtil.writeFromStream(inputStream, file);
} catch (Exception e) {
throw new IllegalArgumentException(CharSequenceUtil.format("{} File read failed", classPathFile.getPath()), e);
throw new IllegalArgumentException(
CharSequenceUtil.format("{} File read or write failed", path), e
);
}
FileUtil.copy(classPathFile, file, true);
}
}
return file;