idea java文件夹,IntelliJ IDEA中的Java项目文件夹结构

What is an acceptable folder structure for Java projects in IntelliJ IDEA?

Multiple sources (like this) suggest the following structure:

.

│ .idea

└── src

├── main

│ ├── java

│ │ └── com.simpleproject

│ │ └── SimpleClass.java

│ └── resources

└── test

├── java

│ └── com.simpleproject

│ └── SimpleClassTest.java

└── resources

I know this has worked before, but right now it is complaining java.lang.SecurityException: Prohibited package name: java

Apparently, java is not allowed as a package name. I don't understand why it's sometimes acceptable and sometimes not acceptable. Can someone provide a complete example of an acceptable project folder structure in a Java project in IntelliJ IDEA?

解决方案

That is the basic folder structure of a maven project. IntelliJ usually recognizes this and sets up sensical defaults for you.

If it didn't (or if it did but you modified them afterwards), you need to set up your java folder as the sources folder (i.e. the folder that contains the source code).

For this, you need to:

Go to your project structure settings: File > Project Structure

Select your project in the middle panel

Select the 'sources' tab in the right panel

Note from a comment (thanks @Line): In IntelliJ 2018.3.5, you "select 'modules' tab in left panel".

Navigate to the src/main/java folder and select it

Mark it as Sources

Repeat for test folder (mark as 'Tests'), resources (mark as 'Resources'), test-resources (mark as 'Test Resources'), etc.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值