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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With