Can't choose class as main class in IntelliJ

后端 未结 3 1275
臣服心动
臣服心动 2021-01-30 07:48

I have a Java project in IntelliJ to which I just added a bunch of files in a nested folder hierarchy. Many of these files are tests and include the main method, so I should be

相关标签:
3条回答
  • 2021-01-30 08:25

    Here is the complete procedure for IDEA IntelliJ 2019.3:

    1. File > Project Structure

    2. Under Project Settings > Modules

    3. Under 'Sources' tab, right-click on 'src' folder and select 'Sources'.

    4. Apply changes.

    0 讨论(0)
  • 2021-01-30 08:39

    The documentation you linked actually has the answer in the link associated with the "Java class located out of the source root." Configure your source and test roots and it should work.

    https://www.jetbrains.com/idea/webhelp/configuring-content-roots.html

    Since you stated that these are tests you should probably go with them marked as Test Source Root instead of Source Root.

    0 讨论(0)
  • 2021-01-30 08:40

    Select the folder containing the package tree of these classes, right-click and choose "Mark Directory as -> Source Root"

    0 讨论(0)
提交回复
热议问题