I am writing a Rest service using spring mvc framework and maven. I am using tomcat server for now. My pom for the project is
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-rest-service</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
This project uses tomcat server and runs on port 8080 by default. can anyone help me understand from where it picks up this configuration and how to change the port on which tomcat runs.
My preliminary analysis tells me there is some configuration done in spring.boot plugin that I need to override in my pom. Can anyone help me in overriding tomcat default port and run it on some other port.
27.3.4 Customizing embedded servlet containers says (in part)
Common servlet container settings can be configured using Spring Environment properties. Usually you would define the properties in your
application.propertiesfile.Common server settings include:
- Network settings: listen port for incoming HTTP requests (
server.port), interface address to bind toserver.address, etc.
So, create a src/main/resources/application.properties and add
server.port=${port:8081}
(or whatever port you want).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With