Spring Boot Tomcat Example

Spring Boot Tomcat Example

Spring Boot made easy to create stand-alone application which you can “just run”. In last tutorial you saw how to create sample Spring Boot Hello World application. In this tutorial we advantage opinionated view of the Spring platform and third-party libraries so we can get started with minimum fuss. As it comes with Embed Tomcat, Jetty or Undertow directly where you don’t need to create WAR file. I will show you how to use embed tomcat server and run sample RestFul web service with minimal configuration:

Tool needed:

  • Eclipse latest version
  • JDK 1.8
  • Maven 3.2.5

Create sample project name: SpringBootTomcat below is final project structure:

Spring Boot Tomcat Example

  • Below is pom.xml file where dependency been included:

  • By default if you don’t provide server port then tomcat will be started at localhost: 8080 and to overwrite this port you will have to create application.properties file insided src/main/resources enter below. I am overwriting 8080 port with 8090 port:
  • application.properties:

  • As to create RestFul service resource below is sample class: RestController.java:

  • MainApps.java: Main class where application starts here you will to add whatever you wan to add and we have created only one resource here: RestController so adding only that one:

  • Now to run the program –> Right click MainApps.java –> Run As Java Application and if everything goes well you will see below out on console:

Spring Boot Tomcat Example

  • Now to check RestFul resource go to browser type below:

Spring Boot Tomcat Example

Spring Boot Tomcat Example

  • For more information please visit Spring Boot official site here

Download project: SpringBootTomcat

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *