简体   繁体   中英

intellij run configuration can't find spring boot class

I am trying to create a run configuration for a spring boot app, but Intellij can't find the main class of the spring boot app (Usually it is automatically populated). I tried adding the class by searching the project structure, but Intellij won't let me add that application's main file to 'Main class' of the configuration. How can I make Intellij detect the class?

Project Directory:

rootfolder
   > springBootBackEnd
   > angularUI

I have the module set to 'rootfolder' and the content root is the rootfolder

Problem may be that you have badly configured IDEA project files.

Close IDEA, delete all .idea files and reimport project.

The same issue occured to me. In my case, it was the project JDK that was not set. The module JDK was set, but not the project one.

Go to File > Project Structure > Project > Project SDK to solve the issue.

I had similar problem. Try File -> Project Structure -> Modules in the middle column click on your project's name and in the right make sure that src folder is marked as Source Folders (blue folder icon and blue text on the right).

I had the similar issue. But I solved by going to File -> Project Structure, then select Modules and delete the content on the right pane(Sources tab). After save it, I was able to add the Spring Boot configuration as usual. Thanks @AlminaS for the lead.

It could be a bad plugin : check your IDEA log through the menu Help -> Show log in... and if your log is full of errors, try disabling that plugin.

The other answers here are correct too, but many folks have posted a problem with "X" plugin cause further plugins to fail to load (I needed spring boot plugin). I've read about various plugin issues including docker, python, php, etc.. This was the case for me, but in my case it was a "toml" plug-in. I can't be sure when I installed/enabled it, but I certainly didn't need it and I found out by reading the log. The other answers here are valid but if someone suggested to just check the log it'd have saved me a couple hours...

What solved the issue for me is to mark the resources folder as Resources Root .

Right click on src/main/resources -> mark directory as -> Resources Root .

This was in addition to that that src/main/kotlin was already marked at Sources Root .

Java SDK 和Tomcat 服务器版本必须兼容。

I had the same issue. I solved it by going to "src->main->java" and then right-click on java and select the option "mark directory as" source root. Then rebuild the pom.xml file to solve the issue..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM