简体   繁体   中英

Intellij Does not have run button when running Springboot Applications

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".

在此处输入图像描述

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

在此处输入图像描述

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)

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.

在此处输入图像描述

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

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

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