8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SpringBoot でポートを変更する

Last updated at Posted at 2020-10-01

環境

  • Windows10
  • IntelliJ IDEA
  • Git Bash

port を変更する

src > main > resources > application.yml に以下を追記します。

application.yml
server:
  port : 8081

実行し、デフォルトポート 8080 から変更されていることを確認します。

$ curl http://localhost:8080/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
curl: (7) Failed to connect to localhost port 8080: Connection refused

$ curl http://localhost:8081/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    13  100    13    0     0    149      0 --:--:-- --:--:-- --:--:--   149
Hello World!

application.properties の場合

src > main > resources > application.properties の場合は以下のように記載します。

application.properties
server.port=8081
8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?