将属性文件添加到 IntelliJ 的类路径 [英] Add a properties file to IntelliJ's classpath

查看:28
本文介绍了将属性文件添加到 IntelliJ 的类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用运行->运行菜单从 IntelliJ IDE 运行一个简单的 Java 程序.它工作正常.现在我想添加 log4j 日志记录.

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.

我在我的项目根目录下添加了一个资源文件夹.我在该文件夹中添加了一个 log4j.properties 文件.我更改了代码以记录某些内容.

I added a resources folder under my project root. I added a log4j.properties file in that folder. I changed the code to log something.

告诉 IntelliJ 在类路径中包含资源文件夹以便看到属性文件的正确方法是什么?

What is the right way to tell IntelliJ to include the resources folder in the classpath so the properties file is seen?

使用 IntelliJ 8,我可以像喝醉的猴子一样猜测并最终让它发挥作用.我现在有 9 个,但我完全不成功.我已经尝试了一个小时.某处的添加到类路径"选项怎么样?/发烟/发泄/咆哮

With IntelliJ 8 I could guess like a drunk monkey and eventually get it to work. I have 9 now and I am wholly unsuccessful. I've been trying for an hour. How about an "Add to classpath" option somewhere? /fume /vent /rant

推荐答案

试试这个:

  • 转到项目结构.
  • 选择您的模块.
  • 在右侧的树中找到文件夹并选择它.
  • 单击该树上方的源"按钮(带有蓝色文件夹),将该文件夹设为源文件夹.

这篇关于将属性文件添加到 IntelliJ 的类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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