How to configure port for a Spring Boot application

前端 未结 30 1616
名媛妹妹
名媛妹妹 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:25

    In the application.properties file, add this line:

    server.port = 65535

    where to place that fie:

    24.3 Application Property Files

    SpringApplication loads properties from application.properties files in the following locations and adds them to the Spring Environment:

    A /config subdirectory of the current directory
    The current directory
    A classpath /config package
    The classpath root
    

    The list is ordered by precedence (properties defined in locations higher in the list override those defined in lower locations).

    In my case I put it in the directory where the jar file stands.

    From:

    https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-application-property-files

提交回复
热议问题