在IntelliJ中创建了 Spring Boot 项目,但在运行时出错。
下面是错误
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
3条答案
按热度按时间j2cgzkjk1#
如果您没有访问TEMP文件夹的权限,就会发生这种情况。
如果您使用IntellijIDE --〉编辑运行配置--〉下面的VM选项更新--Djava.io.tmpdir=c:〈您的路径〉,则可以解决此问题
例如
zpjtge222#
我也遇到了同样的问题。对我来说解决办法是手动打开
TEMP
文件夹以获得权限。我所做的是:
C:\WINDOWS\TEMP
(或仅通过资源管理器导航)1.此时将出现一条Windows警告消息,指出“您没有权限查看此文件夹等”。
1.单击“继续”(您应具有管理员权限)
1.再次通过IntelliJ运行应用程序。
由于IntelliJ在您的Windows帐户下运行,因此应该不会再产生错误。
6tr1vspr3#
我在使用devtools的时候也遇到过这个问题,我在使用Latex的时候设置了TEMP环境变量,可能是这个原因吧。