IntelliJ问题+获取当前工作目录 [英] IntelliJ Problem with+get current working directory

查看:1123
本文介绍了IntelliJ问题+获取当前工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的maven项目结构

Here is my maven project structure


ProjectParent
 -Class1
 -Class2
 -Module1 (another sub directory)
 --Module1Class1
 --Module1Class2

现在当我从IntelliJ运行Module1Class1时工作目录是ProjectParent目录的位置,但是当我从eclipse运行Module1Class1时,我当前的工作directoru是ProjectParent / Module1目录。

Now when I run Module1Class1 from IntelliJ my current working directory is where ProjectParent directory, but when I run Module1Class1 from eclipse, my current working directoru is ProjectParent/Module1 directory.

为什么这在intellij&中有所不同我怎么能改变这个,所以我的当前目录始终是我的类开始执行的地方,就像在这个例子'Module1Class1'目录中一样。

Why this is different in intellij & how can I change this, so my current directory is always from where my class started execution like in this example 'Module1Class1' directory.

推荐答案

您应该编辑模板运行/调试配置,并在工作目录字段中指定 $ MODULE_DIR $ 变量。

You should edit the template Run/Debug configuration and specify $MODULE_DIR$ variable in the Working directory field.

所有新配置都将继承此默认设置,变量将替换为您要运行的模块的目录。

All the new configurations will inherit this default setting and the variable will be substituted with the directory of the module that you want to run.

有一项功能请求,使其成为默认设置,请投票

There is a feature request to make it the default setting, please vote.

这篇关于IntelliJ问题+获取当前工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆