I have setup quite a few Spring Boot projects using the Spring Web Starter dependency in the past and never had any issue spinning up the application in IntelliJIDEA (community edition) including spinning up the embedded Tomcat
But now I've created another application using the initializr and tried to run it on IntelliJIDEA.
The run log doesn't show any error, but it also doesn't show the usual message about successful starting up Tomcat.
This is all I get from the run log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.2)
2024-02-01T15:18:33.880+01:00 INFO 6100 --- [ main] o.t.t.Testspringboot2Application : Starting Testspringboot2Application using Java 21.0.2 with PID 6100 (/home/thomas/IdeaProjects/testspringboot2/target/classes started by thomas in /home/thomas/IdeaProjects/testspringboot2)
2024-02-01T15:18:33.886+01:00 INFO 6100 --- [ main] o.t.t.Testspringboot2Application : No active profile set, falling back to 1 default profile: "default"
2024-02-01T15:18:35.949+01:00 INFO 6100 --- [ main] o.t.t.Testspringboot2Application : Started Testspringboot2Application in 2.796 seconds (process running for 3.911)
Process finished with exit code 0
Am I missing something?
My pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.theiner</groupId>
<artifactId>testspringboot2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>testspringboot2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The solution was quite easy
Reason for the difference in behavior: I selected WAR instead of JAR for the first time when creating the project in initializr
This leads to an additional dependency entry in pom.xml for Tomcat
Two solutions:
<scope>line from pom.xmlor
How to create the run configuration?
Mavenfrom the listRunfield typespring-boot:runand click on OK