Reputation: 1059
I have declared these two dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
and :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
spring-boot-starter-web
already has spring-boot-starter-tomcat
with embedded tomcat-core. As shown here https://stackoverflow.com/a/33419889/1171533
My question is when my project is build and run which of the implementations of spring-boot-starter-tomcat
is chosen to run? And how can I find which one is being used?
Upvotes: 2
Views: 1437
Reputation: 4286
Run mvn dependency:tree
.
Look for this line:
...
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:<version>:provided
...
If you delete
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
the previous output line should be gone and this gets added instead:
...
[INFO] \- org.springframework.boot:spring-boot-starter-web:jar:<version>:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:<version>:compile
...
Upvotes: 2
Reputation: 510
If you are using @RestController(means creating restful services) below dependency you can use
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
if you are using theamleaf , jsp (you want to deploy application as war) you need to include following dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Upvotes: 0
Reputation: 4076
Based on a class instance, you can find various information of the jar that contains that class.
yourInstance.getClass().getPackage().getImplementationVersion()
Upvotes: 1