我正在将一个项目从 Eclipse 转移到 Intellij IDEA。我已经将 jars 添加到 Project Structure -> Libraries 并将它们作为依赖项添加到模块中。 tomcat 服务器已启动并正在运行,因此 Web 应用程序的导航工作正常。
不幸的是,当使用 jar 创建 excel 文件时,出现错误 java.lang.RuntimeException: java.io.IOException: Could not create temporary directory 'C:\path_to_tomcat_installation\temp\poifiles\'
我的问题是 eclipse/tomcat 如何/为什么能够使用 poi 创建 excel 文件而不会出现此错误,而 Intellij IDEA 不能
最佳答案
原来stackoverflow上有很多关于改变java.io.tmpdir的值的问答。
最初我将 Windows 系统变量 CATALINA_TMPDIR 设置为 c:/new/temp/dir,但由于这是系统范围的设置,我最终决定不使用该方法。
最简单直接的方法就是使用CrazyCoders的建议。 在运行 -> 编辑配置下。 在 Tomcat 服务器的服务器选项卡中,在 VM 选项框中输入 -Djava.io.tmpdir=c:/new/temp/dir
关于eclipse - 由于只读属性,在 tomcat 安装基础中分配临时目录导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56350826/