在IntelliJ中创建了一个spring引导项目,但在运行时出现了错误。
下面是错误
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.IllegalStateException: Temp directory 'C:\WINDOWS\TEMP' does not exist
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.13.jar:5.3.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.1.jar:2.6.1]
at com.example.studentapplication.StudentApplication.main(StudentApplication.java:10) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.6.1.jar:2.6.1]
Caused by: java.lang.IllegalStateException: Temp directory 'C:\WINDOWS\TEMP' does not exist
at org.springframework.util.Assert.state(Assert.java:97) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.boot.system.ApplicationTemp.getTempDirectory(ApplicationTemp.java:125) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.system.ApplicationTemp.getPath(ApplicationTemp.java:96) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.system.ApplicationTemp.getDir(ApplicationTemp.java:89) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.servlet.server.SessionStoreDirectory.getValidDirectory(SessionStoreDirectory.java:46) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory.getValidSessionStoreDir(AbstractServletWebServerFactory.java:306) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory.getValidSessionStoreDir(AbstractServletWebServerFactory.java:302) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.configurePersistSession(TomcatServletWebServerFactory.java:439) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.configureSession(TomcatServletWebServerFactory.java:414) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.configureContext(TomcatServletWebServerFactory.java:390) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.prepareContext(TomcatServletWebServerFactory.java:253) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:205) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) ~[spring-boot-2.6.1.jar:2.6.1]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ~[spring-boot-2.6.1.jar:2.6.1]
... 13 common frames omitted发布于 2022-02-09 08:59:31
如果您没有访问临时文件夹的权限,就会发生这种情况。
如果您使用的是
-->编辑运行配置->-Djava.io.tmpdir=c下面的VM选项更新,则使用-Djava.io.tmpdir=c解决方案:
例如
-Djava.io.tmpdir=c:\user\mytempclass发布于 2022-01-11 13:52:51
我在使用devtools时也遇到了这个问题。我已经为使用Latex设置了TEMP环境变量。也许是因为伤口。
https://stackoverflow.com/questions/70302657
复制相似问题