How to run a spring boot application in intellij? - spring-boot

I am trying to run a spring boot application in intellij 2020.1.1 idea by first generating from spring initializer in start.spring.io then open it with intellij. But when I try the application it doesn't have any output.
Can anyone help me with this? Is this a problem of windows defender?

Try opening the project using the pom.xml file (instead of the project map). File > Open... > select pom.xml
Trust the project when asked.
Run maven when recognized as a maven build.
(Right now there is no maven tab on the right.)
When the maven build is recognized a *.iml will be created and a project configuration will be added to your configurations.
Now you can just press 'run' at the top (or press shift + F10)
Tip: you can also just drag and drop pom files on the start screen and it will open the project.

Click on the run button in Main Class. It will automatically start your project. It worked for me.

Related

Springboot not recognized on IntelliJ

Even after installing Java and Maven, creating a spring project from springinitializr is facing an issue. The issue is that the project is not recognised as spring project, the annotations, import nothing are working. Can anyone please help out
I tried to redo the process, but things were same. Is any settings.xml needs to be made but I don't see it as necessity.
When opening your project in intellij. you should do so via the import > new Project and choose the pom.xml for the generated project from spring initialize. This way it can resolve dependencies and properly open your project.
if the problem persists you can go to your MainApplication.java > right click > run as spring boot project.
If it does not put the configuration on the run shortcut on the up right of the application you can configure it by adding the command : mvn spring-boot:run and add other configurations id desired.

No maven in intellij idea

I have one project open in IntelliJ. In that I am able to see maven tab in its left sidebar:
Also, I am able to see Maven in View > Tool Windows > Maven:
I tried to open another project in another IntelliJ window, but it does not have both of the above:
It may be not required to have that maven tool window for the project that you have opened in the second Idea instance.
If the opened project is a maven project (at least if you have a pom.xml associated with that project) you will have this option available in View -> Tool Windows -> maven
If it's a maven project, try importing the project as a maven project as well

How do I run the Spring RESTful Web Service

I've installed the spring example RESTful Web Service. And I have it building fine in IntelliJ. But how do I get IntelliJ to create gs-rest-service-0.1.0.jar? There are menu commands to synchronize gradle & maven, but nothing to use them to build the jar.
A standard POM/Maven-based project can be built via the console by typing:
mvn package
the maven lifecycle, by default, will place the output artifact (i.e. JAR / WAR file) under the target folder.
Alternatively, since you are using IntelliJ, you can also use the IDE to run the build for you. The simplest way is to navigate on the right side tab
mvn > your_project > lifecycles > package
the output will continue to be placed in the same target folder.
Assuming the project has a pom file. And it was mentioned building fine in the post. Assumption: STS/Eclipse users
Right click on pom file -> run as maven build. In the console it displays where the jar file is created.
Go to: project folder -> target folder -> gs-rest-service-0.1.0.jar
file

IntelliJ "Run Maven Build" greyed out

I have a Maven/Spring Boot project built in IntelliJ. As far as I can tell, everything seems to run nicely from within IntelliJ.
I have it setup to package to a stand-alone jar with embedded Tomcat:
<packaging>jar</packaging>
I am using:
spring-boot-starter-parent
So, my understanding is that I don't need "repackage" under an executions tag in my pom file.
I would like to start experimenting with deploying the project, and went in to try to do the build to get the JAR. But the "Run Maven Build" arrow under when I right click the project under "Maven Projects" is greyed out. Any ideas as to what might be the cause of this or what I should double check?
You need to select a plugin which Intellij can tell Maven to run. Since you are using Spring Boot and your question referred to "package to a stand-alone jar with embedded Tomcat" and "deploying the project" the plugin you want to use is: spring-boot-maven-plugin.
So, if you add this plugin to your POM as follows ...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
...then you'll see spring-boot under Maven Projects > project_name > Plugins.
When you select any node under spring-boot, the Run button will be enabled, but it will be disabled for the root node since the root node (i.e. your project) is not deemed to be runnable in and of itself.
Here's a screenshot when selecting the root node (the Run button is disabled):
And here's a screenshot when selecting the spring-boot node (the Run button is enabled):
Clicking on Run Maven Build once you have selected spring-boot:run will cause IntelliJ to invoke the run goal of spring-boot-maven-plugin which will start your application including its embedded Tomcat container.

IntelliJ run configurations for Netbeans RCP project

there's a project I'm working on with a team (BUMMEL) and we've migrated it's build tool from Ant to Maven, to make it IDE-agnostic, and now I can open it into IntelliJ as a Maven project but I have troubles creating the run configuration for it.
Can anyone suggest me how to create a Run configuration? Also any other suggestions about running NetBeans-RCP maven-based project on IntelliJ are appreciated.
It looks like you should go to Edit Configurations... and add new Maven configuration.
Then put in Working directory: field a path you your app module, for me its application/ in the project root.
And in Command line: field put nbm:cluster-app nbm:run-platform.
Now you can run your app by selecting a newly created configuration and pressing a green "Play" arrow.

Resources