IntelliJ does not show 'Class' when we rig

2019-01-21 02:07发布

We're creating a new project in IntelliJ and must have something wrong because when we right click on a directory, select New and then get the context menu, Java based options are not shown. Currently get things like File, some HTML options, XML options.

We have assumed so far it's something we haven't configured correctly in the Project/Module configuration. The new module we are talking about is part of a multi module project. We created it using a Maven web archetype.

Any help configuring the project nature?

Edit: The answer is basic: 'That moment when you realise somethings not working because you haven't been clicking 'Apply'... :) We had a good laugh at ourselves when we discovered this'

7条回答
相关推荐>>
2楼-- · 2019-01-21 02:50

If you open your module settings (F4) you can nominate which paths contain 'source'. Intellij will then mark these directories in blue and allow you to add classes etc.

In a similar fashion you can highlight test directories for unit tests.

查看更多
The star\"
3楼-- · 2019-01-21 02:53

Had this issue too. Invalidating Caches/Restart did the trick for me. Please upvote so the the IntelliJ folks take this more seriously. This gives the IDE a terrible UI/UX experience.

https://youtrack.jetbrains.com/issue/IDEA-203100

查看更多
闹够了就滚
4楼-- · 2019-01-21 03:02

The directory or one of the parent directories must be marked as Source Root (In this case, it appears in blue).

If this is not the case, right click your root source directory -> Mark As -> Source Root.

查看更多
Melony?
5楼-- · 2019-01-21 03:03

you need to mark your directory as source root (right click on the parent directory)

and then compile the plugin (it is important )

as result you will be able to add classes and more

enter image description here

enter image description here

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-21 03:06

Project Structure->Modules->{Your Module}->Sources->{Click the folder named java in src/main}->click the blue button which img is a blue folder,then you should see the right box contains new item(Source Folders).All be done;

查看更多
该账号已被封号
7楼-- · 2019-01-21 03:07

This can also happen if your package name is invalid.

For example, if your "package" is com.my-company (which is not a valid Java package name due to the dash), IntelliJ will prevent you from creating a Java Class in that package.

查看更多
登录 后发表回答