Accepted answer

the problem is that in intellij, the compilation target is the project folder itself

when building project/module, the ide includes into compile classpath all files/sources from the folders which are marked as source/resource/generated source/test source etc type.

also note that for the case of a maven (gradle) projects ide takes configuration, including compiler configuration, from the maven pom.xml files. by default maven will not process (copy) resource files from the directory with sources. you need to explicitly configure it in pom.xml or move the resource files into folder that will be of a resource type.

now about the main question:

...manually editing the run configuration so that the working directory is in the module root.

my question is, can i somehow change intellij to have this behavior by default for every project instead of having to manually do it every time?

you can change the run/debug configuration template

Related Query

More Query from same tag