Unable to create tempDir. java.io.tmpdir is set to C:\Users\SRV-DA~1\AppData\Local\Temp\5\
1.问题描述
在Windows server下,跑了几个月的程序,突然报警了,我也很无语
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to C:\Users\SRV-DA~1\AppData\Local\Temp\5\
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:576) ~[spring-context-5.3.4.jar!/:5.3.4]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) [spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) [spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.4.3.jar!/:2.4.3]
at com.delta.DmsReplaceSapFileApplication.main(DmsReplaceSapFileApplication.java:13) [classes!/:0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_191]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [dms-replace-sap-file-0.1-SNAPSHOT.jar:0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) [dms-replace-sap-file-0.1-SNAPSHOT.jar:0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [dms-replace-sap-file-0.1-SNAPSHOT.jar:0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [dms-replace-sap-file-0.1-SNAPSHOT.jar:0.1-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to C:\Users\SRV-DA~1\AppData\Local\Temp\5\
at org.springframework.boot.web.server.AbstractConfigurableWebServerFactory.createTempDir(AbstractConfigurableWebServerFactory.java:195) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:186) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.4.3.jar!/:2.4.3]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) ~[spring-boot-2.4.3.jar!/:2.4.3]
... 17 common frames omitted
Caused by: java.nio.file.NoSuchFileException: C:\Users\SRV-DA~1\AppData\Local\Temp\5\tomcat.8082.2026523687593087531
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source) ~[na:1.8.0_191]
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) ~[na:1.8.0_191]
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) ~[na:1.8.0_191]
at sun.nio.fs.WindowsFileSystemProvider.createDirectory(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.Files.createDirectory(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.TempFileHelper.create(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.TempFileHelper.createTempDirectory(Unknown Source) ~[na:1.8.0_191]
at java.nio.file.Files.createTempDirectory(Unknown Source) ~[na:1.8.0_191]
at org.springframework.boot.web.server.AbstractConfigurableWebServerFactory.createTempDir(AbstractConfigurableWebServerFactory.java:189) ~[spring-boot-2.4.3.jar!/:2.4.3]
... 20 common frames omitted
- 报警Unable to create tempDir. java.io.tmpdir is set to C:\Users\SRV-DA~1\AppData\Local\Temp\5\
- SRV-DA~1为什么变成这样,我也不知道(就是当前用户名SRV-Data)
- 报警的意思就是临时路径找不到\temp\5\
2.解决方法
@Configuration(proxyBeanMethods = false)
public class MultipartConfig {
@Bean
MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
String location = System.getProperty("user.home") + "/AppData/Local/Temp";
File tmpFile = new File(location);
if (!tmpFile.exists()) {
tmpFile.mkdirs();
}
factory.setLocation(location);
return factory.createMultipartConfig();
}
}
server.tomcat.basedir=xxxxxx
3.好奇
查看了一下,用户名下面确实好多临时文件夹
|