项目中,使用嵌入式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中该方法的工作目录:

idea和eclipse中getAbsolutePath()方法获取值不同

idea和eclipse中getAbsolutePath()方法获取值不同

重新设置为module目录即可

idea和eclipse中getAbsolutePath()方法获取值不同

相关文章:

  • 2021-06-12
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-07
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-12-06
  • 2021-11-06
  • 2021-07-22
相关资源
相似解决方案