Resolve port conflicts in masterdata-service: update application.yml with separated bind addresses (Spring: 127.0.0.1, Ktor: 0.0.0.0), change management port to 8086, and add explicit datasource and Flyway configuration. Fix startup issues with Database.connect() in MasterdataDatabaseConfiguration.
This commit is contained in:
+3
-2
@@ -26,6 +26,7 @@ class KtorServerConfiguration {
|
||||
@Bean
|
||||
fun ktorServer(
|
||||
@Value("\${masterdata.http.port:8091}") port: Int,
|
||||
@Value("\${masterdata.http.address:0.0.0.0}") host: String,
|
||||
meterRegistry: MeterRegistry,
|
||||
countryController: CountryController,
|
||||
bundeslandController: BundeslandController,
|
||||
@@ -37,8 +38,8 @@ class KtorServerConfiguration {
|
||||
funktionaerController: FunktionaerController,
|
||||
regulationController: RegulationController
|
||||
): EmbeddedServer<NettyApplicationEngine, NettyApplicationEngine.Configuration> {
|
||||
log.info("Starting Masterdata Ktor server on port {}", port)
|
||||
val engine = embeddedServer(Netty, port = port) {
|
||||
log.info("Starting Masterdata Ktor server on {}:{}", host, port)
|
||||
val engine = embeddedServer(Netty, port = port, host = host) {
|
||||
masterdataApiModule(
|
||||
countryController = countryController,
|
||||
bundeslandController = bundeslandController,
|
||||
|
||||
+8
-1
@@ -8,9 +8,11 @@ import at.mocode.masterdata.infrastructure.persistence.reiter.ReiterTable
|
||||
import at.mocode.masterdata.infrastructure.persistence.verein.VereinTable
|
||||
import jakarta.annotation.PostConstruct
|
||||
import jakarta.annotation.PreDestroy
|
||||
import org.jetbrains.exposed.v1.jdbc.Database
|
||||
import org.jetbrains.exposed.v1.jdbc.SchemaUtils
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.Profile
|
||||
|
||||
@@ -22,7 +24,11 @@ import org.springframework.context.annotation.Profile
|
||||
*/
|
||||
@Configuration
|
||||
@Profile("!test")
|
||||
class MasterdataDatabaseConfiguration {
|
||||
class MasterdataDatabaseConfiguration(
|
||||
@Value("\${spring.datasource.url}") private val jdbcUrl: String,
|
||||
@Value("\${spring.datasource.username}") private val username: String,
|
||||
@Value("\${spring.datasource.password}") private val password: String
|
||||
) {
|
||||
|
||||
private val log = LoggerFactory.getLogger(MasterdataDatabaseConfiguration::class.java)
|
||||
|
||||
@@ -31,6 +37,7 @@ class MasterdataDatabaseConfiguration {
|
||||
log.info("Initializing database schema for Masterdata Service...")
|
||||
|
||||
try {
|
||||
Database.connect(jdbcUrl, user = username, password = password)
|
||||
// Spring Boot should initialize database connection
|
||||
transaction {
|
||||
SchemaUtils.create(
|
||||
|
||||
@@ -3,13 +3,23 @@ spring:
|
||||
name: masterdata-service
|
||||
main:
|
||||
banner-mode: "off"
|
||||
datasource:
|
||||
url: ${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/pg-meldestelle-db}
|
||||
username: ${SPRING_DATASOURCE_USERNAME:pg-user}
|
||||
password: ${SPRING_DATASOURCE_PASSWORD:pg-password}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
flyway:
|
||||
enabled: true
|
||||
baseline-on-migrate: true
|
||||
|
||||
server:
|
||||
port: 8081 # Spring Boot Management Port (Actuator)
|
||||
port: 8086 # Spring Boot Management Port (Actuator & Tomcat)
|
||||
address: 127.0.0.1 # Sicherheit: Nur lokal erreichbar
|
||||
|
||||
masterdata:
|
||||
http:
|
||||
port: 8091 # Ktor API Port
|
||||
port: 8091 # Ktor API Port (Haupt-Einstiegspunkt für REST-Anfragen)
|
||||
address: 0.0.0.0 # Öffentlich erreichbar innerhalb des Netzwerks / Containers
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
|
||||
Reference in New Issue
Block a user