Mer*_*ial 2 java tomcat maven spring-boot
我正在使用spring mvc框架和maven编写Rest服务.我现在正在使用tomcat服务器.我的项目是pom
<?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>
Run Code Online (Sandbox Code Playgroud)
该项目使用tomcat服务器并默认在端口8080上运行.任何人都可以帮助我理解它从哪里获取此配置以及如何更改运行tomcat的端口.
我的初步分析告诉我在spring.boot插件中完成了一些配置,我需要在我的pom中覆盖它.任何人都可以帮助我覆盖tomcat默认端口并在其他端口上运行它.
可以使用Spring Environment属性配置公共servlet容器设置.通常,您将在
application.properties文件中定义属性.常用服务器设置包括:
- 网络设置:侦听传入HTTP请求的端口(
server.port),要绑定的接口地址server.address等.
所以,创建一个src/main/resources/application.properties并添加
server.port=${port:8081}
Run Code Online (Sandbox Code Playgroud)
(或任何你想要的端口).
| 归档时间: |
|
| 查看次数: |
5575 次 |
| 最近记录: |