From 1f5cc92aa40896de333a6f81bfe686dd347a3591 Mon Sep 17 00:00:00 2001 From: Lauro Correia Silveira Date: Tue, 19 Dec 2023 10:57:59 +0100 Subject: [PATCH] Added port configuration to deploy on railway --- .../infraestructure/railway/RailwayConfig.java | 13 +++++++++++++ src/main/resources/application.yml | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java diff --git a/src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java b/src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java new file mode 100644 index 0000000..913d972 --- /dev/null +++ b/src/main/java/com/alura/aluraflixapi/infraestructure/railway/RailwayConfig.java @@ -0,0 +1,13 @@ +package com.alura.aluraflixapi.infraestructure.railway; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RailwayConfig { + + @Bean + String getPort(){ + return System.getenv("PORT"); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c940c3f..d876532 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: ${PORT:8080} # Disable StackTrace of Spring on response when an error happen error: include-stacktrace: never