デフォルトではTomCatが 8080ポートで起動します。
$ ./gradlew bootrun
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.5)
... : Tomcat initialized with port(s): 8080 (http)
Code language: plaintext (plaintext)
Jenkinsなどの別のアプリケーションがすでに8080ポートを使っていると、エラーで起動しません。
Caused by: java.net.BindException: アドレスは既に使用中です
Code language: plaintext (plaintext)
Spring Bootのポートを8080以外に、例えば 12345 に設定するには、
myapp/src/main/resources/application.properties
に
server.port=12345
Code language: plaintext (plaintext)
を記述します。