简体   繁体   English

Intellij 在运行 Springboot 应用程序时没有运行按钮

[英]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 运行。

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

  2. Go to the main class and run or add configuration from the menu Go 到主 class 并从菜单运行或添加配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IntelliJ IDEA 运行应用程序 - IntelliJ IDEA Run applications IntelliJ 不会在运行/调试配置中将“应用程序”显示为选项 - IntelliJ does not show "Applications" as an option in Run/Debug Configurations Springboot 应用程序未通过 IntelliJ 在端口中运行 - Springboot app not running in port through IntelliJ 有没有办法在 IntelliJ IDEA 中使用单个运行配置运行多个 Spring Boot 应用程序? - Is there a way to run multiple Spring Boot applications with a single Running Configuration in IntelliJ IDEA? 如果没有JVM,Android如何运行Java应用程序 - How does android run java applications if it doesnt have a JVM 运行整个套件时 IntelliJ / Springboot 中的奇怪测试用例失败 - 自行成功 - Odd Test Case Failure in IntelliJ / Springboot when Running Entire Suite - Succeeds by Itself 更改后运行单元测试不会在 IntelliJ 中运行更新的测试 - Running a unit test after changing it does not run the updated test in IntelliJ SpringBoot 添加到dependencyManagement 时不运行单元测试 - SpringBoot does not run unit tests when added into dependencyManagement Springboot作为systemd服务运行时找不到环境变量 - Springboot does not find environment variables when run as a systemd service 在IntelliJ中运行所有测试时运行预集成阶段 - Run pre-integration-phase when running all tests in IntelliJ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM