Let’s say we have a Maven Spring Boot WAR project that we want to debug as fat JAR. This works out of the box in Eclipse if we add the following dependencies:
<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-devtools</artifactId> </dependency>
Sadly in IntelliJ this won’t work. When you try to run your application from the IDE it will crash because of missing dependencies. The problem is that the dependencies with the “provided” scope are not injected at runtime by the IDE. I consider this to be a bug, given the fact that these dependencies are marked as provided, exactly because we need them during development but they must be provided at runtime by the environment. Anyways, to fix this we can add a new profile to our POM file:
<profiles> <profile> <id>DEVEL</id> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency> </dependencies> </profile> </profiles>
The newly created DEVEL profile defines the spring-boot-starter-tomcat dependency as regular dependency. Note that we can’t simply remove the “provided” scope from our default profile because that will crash the runtime environment. Our WAR should not contain spring-boot-starter-tomcat! We only need this during development.
In IntelliJ we need to activate the DEVEL profile using the Maven Projects tab, and we are good to go:
Lastly, if you found this post useful, please feel free to share + give it a LIKE, so others can find it too! Thanks 😊