idea和eclipse中getAbsolutePath()方法获取值不同
Posted 花花牛
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了idea和eclipse中getAbsolutePath()方法获取值不同相关的知识,希望对你有一定的参考价值。
项目中,使用嵌入式tomcat启动web工程(具体使用请度娘,关键字: tomcat embeded)
启动时,设置tomcat path的代码如下:
Embedded tomcat = new Embedded(); String baseDir = new File(".").getAbsolutePath(); tomcat.setCatalinaHome(baseDir + "/src/test/resources/tomcat-home");
在eclipse中运行正常,但是在idea中异常;
debug后发现,getAbsolutePath()方法获取的值不同,idea中获取的不是module的路径,而是项目根路径;
设置idea中该方法的工作目录:
重新设置为module目录即可
以上是关于idea和eclipse中getAbsolutePath()方法获取值不同的主要内容,如果未能解决你的问题,请参考以下文章