Spring Boot - 如何配置端口 [英] Spring Boot - how to configure port

查看:215
本文介绍了Spring Boot - 如何配置端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找如何在Spring启动应用程式中设定连接埠的方式:

Looking for way how to configure port in Spring boot app:

@Controller
@EnableAutoConfiguration
public class SampleController {

    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, args);
    }
}

这是所有来源:)

推荐答案

正如docs http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-change-the-http-port

使用命令行选项将 server.port 设置为系统属性jvm - 服务器.port = 8090 或在 / src / main / resources / 中添加 application.properties

either set server.port as system property using command line option to jvm --server.port=8090 or add application.properties in /src/main/resources/ with

server.port = 8090

对于随机端口使用

server.port=0

这篇关于Spring Boot - 如何配置端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆