java - How to change port number for tomcat server using maven -
i writing rest service using spring mvc framework , maven. using tomcat server now. pom project
<?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 , runs on port 8080 default. can me understand picks configuration , how change port on tomcat runs.
my preliminary analysis tells me there configuration done in spring.boot plugin need override in pom. can me in overriding tomcat default port , run on other port.
27.3.4 customizing embedded servlet containers says (in part)
common servlet container settings can configured using spring environment properties. define properties in
application.properties
file.common server settings include:
- network settings: listen port incoming http requests (
server.port
), interface address bindserver.address
, etc.
so, create src/main/resources/application.properties
, add
server.port=${port:8081}
(or whatever port want).
Comments
Post a Comment