[英]Intellij Does not have run button when running Springboot Applications
I downloaded Intellij to follow a Springboot tutorial.我下载了 Intellij 以遵循 Springboot 教程。 It begins by going to Spring Initializr to get all relevant dependencies in a folder and open it up on Intellij.
它首先转到 Spring Initializr 以获取文件夹中的所有相关依赖项并在 Intellij 上打开它。 As I open up Intellij, the run button is not visible.
当我打开 Intellij 时,运行按钮不可见。 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"如果我为一个普通的 java 程序打开 Intellij,我可以很容易地点击运行并选择“Main.java”
This is a freshly installed Intellj and settings were set up as default.这是一个新安装的 Intellj,设置为默认设置。 Is there a trick to find the run button when dealing with Springboot?
在处理 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.编辑 1:我尝试右键单击 src 目录和 select 选项 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.编辑 2:我尝试添加新配置 --> 添加新配置 --> 应用程序 --> 然后查找名为“DemoApplication”的 Main class 但未找到。 (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.
你的文件夹结构看起来像 demo/demo/src。
You imported the project at demo
whereas you should have imported it at demo/demo
.您在
demo
导入了项目,而您应该在demo/demo
导入它。 When you import it you want src/
and pom.xml
to be at the root of the project.当您导入它时,您希望
src/
和pom.xml
位于项目的根目录。 Also when you import it the src/
folder should be blue, that is how you know you have imported it correctly.此外,当您导入它时,
src/
文件夹应该是蓝色的,这就是您知道您已正确导入它的方式。
As a rule of thumb you should always make sure a pom.xml is at the root of the import when working with maven根据经验,在使用 maven 时,您应该始终确保 pom.xml 位于导入的根目录
you have to set project SDK first, then it can be run from main class.你必须先设置项目 SDK,然后它可以从主 class 运行。
File -> project structure -> project -> set project SDK from dropdown, download or browse jdk bin path File -> project structure -> project -> set project SDK from dropdown,下载或浏览jdk bin路径
short key: CTRL+ALT+SHIFT+S快捷键:CTRL+ALT+SHIFT+S
Go to the main class and run or add configuration from the menu Go 到主 class 并从菜单运行或添加配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.