Add a properties file to IntelliJ's classpath

后端 未结 10 2309
栀梦
栀梦 2020-11-28 19:20

I\'m running a simple Java program from the IntelliJ IDE using the Run->Run menu. It works fine. Now I want to add log4j logging.

I added a resources folder under my

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 20:04

    If you ever end up with the same problem with Scala and SBT:

    • Go to Project Structure. The shortcut is (CTRL + ALT + SHIFT + S)

    • On the far left list, choose Project Settings > Modules

    • On the module list right of that, select the module of your project name (without the build) and choose the sources tab

    • In middle, expand the folder that the root of your project for me that's /home//IdeaProjects/

    • Look at the Content Root section on the right side, the red paths are directories that you haven't made. You'll want to put the properties file in a Resources directory. So I created src/main/resources and put log4j.properties in it. I believe you can also modify the Content Root to put it wherever you want (I didn't do this).

    • I ran my code with a SBT configuration and it found my log4j.properties file.

提交回复
热议问题