When we use Spring Boot to write a batch application, the program is just used for background running batch data. At this time, it is not necessary to build Tomcat, simplify the start-up mode to start projects using non-Web mode. Spring Boot provides a convenient way of configuring dependencies with its starters. How do I run a spring boot jar in Tomcat? Create a Spring Boot Project for Tomcat. Leave as Maven, Java, and the latest stable Spring Boot (2.1. Change the group and artifact if you wish. Click on More options and select Java 11. In the Dependencies box, type. Spring Boot - Tomcat Port Number - Spring Boot lets you to run the same application more than once on a different port number. In this chapter, you will learn about this in detail.
- Spring Boot Tutorial
- Spring Boot Resources
- Selected Reading
Spring Boot Starter Tomcat
This chapter will teach you how to create a Spring Boot application using Maven and Gradle.
Your system need to have the following minimum requirements to create a Spring Boot application −
- Java 7
- Maven 3.2
- Gradle 2.5
Spring Boot CLI
The Spring Boot CLI is a command line tool and it allows us to run the Groovy scripts. This is the easiest way to create a Spring Boot application by using the Spring Boot Command Line Interface. You can create, run and test the application in command prompt itself.
This section explains you the steps involved in manual installation of Spring Boot CLI. For further help, you can use the following link: https://docs.spring.io/springboot/ docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-installing-springboot
You can also download the Spring CLI distribution from the Spring Software repository at: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-manual-cli-installation
For manual installation, you need to use the following two folders −
Spring Boot Start Tomcat Online
After the download, unpack the archive file and follow the steps given in the install.txt file. Not that it does not require any environment setup.
Spring Boot Start Tomcat On Different Port
In Windows, go to the Spring Boot CLI bin directory in the command prompt and run the command spring –-version to make sure spring CLI is installed correctly. After executing the command, you can see the spring CLI version as shown below −
Run Hello World with Groovy
Create a simple groovy file which contains the Rest Endpoint script and run the groovy file with spring boot CLI. Observe the code shown here for this purpose −
Now, save the groovy file with the name hello.groovy. Note that in this example, we saved the groovy file inside the Spring Boot CLI bin directory. Now run the application by using the command spring run hello.groovy as shown in the screenshot given below −
Once you run the groovy file, required dependencies will download automatically and it will start the application in Tomcat 8080 port as shown in the screenshot given below −
Once Tomcat starts, go to the web browser and hit the URL http://localhost:8080/ and you can see the output as shown.