How to configure port for a Spring Boot application

前端 未结 30 1736
名媛妹妹
名媛妹妹 2020-11-22 13:36

How do I configure the TCP/IP port listened on by a Spring Boot application, so it does not use the default port of 8080.

30条回答
  •  礼貌的吻别
    2020-11-22 14:22

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

    server.port=8090
    

    For random port use

    server.port=0
    

    Similarly add application.yml in /src/main/resources/ with

    server:
      port : 8090
    

提交回复
热议问题