Home > other >  Intellij Does not have run button when running Springboot Applications
Intellij Does not have run button when running Springboot Applications

Time:02-14

I downloaded Intellij to follow a Springboot tutorial. It begins by going to Spring Initializr to get all relevant dependencies in a folder and open it up on Intellij. As I open up Intellij, the run button is not visible. Instead it says "Add Configuration".

enter image description here

If I open up Intellij for a normal java program, I was easily able to click run and choose "Main.java"

enter image description here

This is a freshly installed Intellj and settings were set up as default. Is there a trick to find the run button when dealing with Springboot? I tried doing as if it was a normal program but as you can see, I can't find it. I tried looking up similar questions but there doesn't seem any that matches mine. I would appreciate any help. Thank you!

EDIT 1: I tried right clicking on src directory and select option Mark Directory As > Sources Root. But breaks program instead.

EDIT 2: I tried adding a new configuration --> Add new --> Application --> then look for Main class entitled 'DemoApplication' but its not found. (I thought that this would be my main class)

CodePudding user response:

You have imported the project at the wrong folder level. your folder structure seems to be like demo/demo/src.

You imported the project at demo whereas you should have imported it at demo/demo. When you import it you want src/ and pom.xml to be at the root of the project. Also when you import it the src/ folder should be blue, that is how you know you have imported it correctly.

enter image description here

As a rule of thumb you should always make sure a pom.xml is at the root of the import when working with maven

CodePudding user response:

you have to set project SDK first, then it can be run from main class.

  1. File -> project structure -> project -> set project SDK from dropdown, download or browse jdk bin path

    short key: CTRL ALT SHIFT S

  2. Go to the main class and run or add configuration from the menu

CodePudding user response:

go eclipse, Easier to use for beginners

  • Related