Skip to main content
This guide covers the configuration of all services in the StreamLine Logistics platform, including Spring Boot properties, database connections, and service discovery.

Configuration Overview

StreamLine Logistics uses Spring Boot’s YAML-based configuration. Each microservice has its own application.yml or application.properties file located in src/main/resources/.

Project Configuration

Maven Configuration (pom.xml)

The root pom.xml defines project-wide settings:
<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <maven.compiler.release>17</maven.compiler.release>
  <org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
  <org.projectlombok.version>1.18.28</org.projectlombok.version>
  <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
</properties>
Key Dependencies:
  • Spring Boot: 4.0.2
  • Spring Cloud: 2025.1.0
  • Java Version: 17
  • Lombok: 1.18.28
  • MapStruct: 1.5.5.Final
  • JaCoCo: 0.8.14 (code coverage)
All microservices inherit from spring-boot-starter-parent version 4.0.2.

Eureka Server Configuration

Service discovery and registration server.

Application Configuration

File: microservice-eureka/src/main/resources/application.yml
server:
  port: 8761

spring:
  application:
    name: msvc-eureka
  config:
    import: "optional:configserver:http://localhost:8888"

eureka:
  instance:
    hostname: eureka-server
  client:
    register-with-eureka: false
    fetch-registry: false
    server-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

Configuration Breakdown

PropertyValueDescription
server.port8761Eureka dashboard and API port
spring.application.namemsvc-eurekaService identifier
eureka.client.register-with-eurekafalseDon’t register with itself
eureka.client.fetch-registryfalseDon’t fetch registry (standalone)
eureka.instance.hostnameeureka-serverContainer hostname

Accessing Eureka Dashboard

# Local
http://localhost:8761

# Inside Docker network
http://eureka-server:8761

Order Service Configuration

Handles order management with PostgreSQL database.

Application Configuration

File: microservice-order/src/main/resources/application.yml
server:
  port: 8090

spring:
  application:
    name: msvc-order
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://order_db:5432/orderdb
    username: postgres
    password: password
  jpa:
    hibernate:
      ddl-auto: create
    database: postgresql
    database-platform: org.hibernate.dialect.PostgreSQLDialect
  config:
    import: "optional:configserver:http://localhost:8888"

eureka:
  instance:
    hostname: eureka-server
  client:
    service-url:
      defaultZone: http://${eureka.instance.hostname}:8761/eureka/

Configuration Breakdown

Server Configuration

PropertyValueDescription
server.port8090REST API port
spring.application.namemsvc-orderService name in Eureka

Database Configuration

PropertyValueDescription
spring.datasource.driver-class-nameorg.postgresql.DriverPostgreSQL JDBC driver
spring.datasource.urljdbc:postgresql://order_db:5432/orderdbDatabase connection URL
spring.datasource.usernamepostgresDatabase user
spring.datasource.passwordpasswordDatabase password
The hibernate.ddl-auto: create setting drops and recreates tables on startup. Change to update or validate in production.

JPA Configuration

PropertyValueDescription
spring.jpa.hibernate.ddl-autocreateSchema generation strategy
spring.jpa.databasepostgresqlDatabase type
spring.jpa.database-platformorg.hibernate.dialect.PostgreSQLDialectHibernate dialect

Eureka Client Configuration

PropertyValueDescription
eureka.client.service-url.defaultZonehttp://eureka-server:8761/eureka/Eureka server URL

Dependencies (pom.xml)

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
  </dependency>
  <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <scope>runtime</scope>
  </dependency>
</dependencies>

Inventory Service Configuration

Manages inventory with MySQL database.

Application Configuration

File: microservice-inventory/src/main/resources/application.yml
server:
  port: 9090

spring:
  application:
    name: msvc-inventory
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://inventory_db:3306/inventorydb
    username: root
    password: password
  jpa:
    hibernate:
      ddl-auto: create
    database: mysql
    database-platform: org.hibernate.dialect.MySQLDialect
  config:
    import: "optional:configserver:http://localhost:8888"

eureka:
  instance:
    hostname: eureka-server
  client:
    service-url:
      defaultZone: http://${eureka.instance.hostname}:8761/eureka/

Configuration Breakdown

Server Configuration

PropertyValueDescription
server.port9090REST API port
spring.application.namemsvc-inventoryService name in Eureka

Database Configuration

PropertyValueDescription
spring.datasource.driver-class-namecom.mysql.cj.jdbc.DriverMySQL JDBC driver
spring.datasource.urljdbc:mysql://inventory_db:3306/inventorydbDatabase connection URL
spring.datasource.usernamerootDatabase user
spring.datasource.passwordpasswordDatabase password

JPA Configuration

PropertyValueDescription
spring.jpa.hibernate.ddl-autocreateSchema generation strategy
spring.jpa.databasemysqlDatabase type
spring.jpa.database-platformorg.hibernate.dialect.MySQLDialectHibernate dialect

Dependencies (pom.xml)

<dependencies>
  <!-- Spring Boot Starters -->
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
  </dependency>
  
  <!-- Spring Cloud -->
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
  </dependency>
  
  <!-- Database -->
  <dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <scope>runtime</scope>
  </dependency>
  
  <!-- Documentation -->
  <dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>3.0.2</version>
  </dependency>
</dependencies>
The Inventory Service includes SpringDoc OpenAPI for automatic API documentation. Access it at http://localhost:9090/swagger-ui.html

Tracking Service Configuration

Tracks shipments using MongoDB.

Application Configuration

File: microservice-tracking/src/main/resources/application.yml
server:
  port: 8091

mongodb:
  user: root
  password: password
  database: trakcingdb

spring:
  application:
    name: msvc-tracking
  data:
    mongodb:
      uri: mongodb://${mongodb.user}:${mongodb.password}@localhost:27017/${mongodb.database}
  jpa:
    hibernate:
      ddl-auto: create
    database: postgresql
    database-platform: org.hibernate.dialect.PostgreSQLDialect
  config:
    import: "optional:configserver:http://localhost:8888"

eureka:
  instance:
    hostname: eureka-server
  client:
    service-url:
      defaultZone: http://${eureka.instance.hostname}:8761/eureka/
There’s a typo in the database name: trakcingdb should be trackingdb. Also note the MongoDB URI uses localhost but should use tracking_db when running in Docker.

Configuration Breakdown

Server Configuration

PropertyValueDescription
server.port8091REST API port
spring.application.namemsvc-trackingService name in Eureka

MongoDB Configuration

PropertyValueDescription
mongodb.userrootMongoDB username
mongodb.passwordpasswordMongoDB password
mongodb.databasetrakcingdbDatabase name
spring.data.mongodb.urimongodb://…Full connection URI
For Docker deployment, change the MongoDB URI to use tracking_db instead of localhost:
uri: mongodb://${mongodb.user}:${mongodb.password}@tracking_db:27017/${mongodb.database}

Dependencies (pom.xml)

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
  </dependency>
</dependencies>

Gateway Configuration

API Gateway for routing requests to microservices. File: microservice-gateway/src/main/resources/application.properties
spring.application.name=microservice-gateway
The Gateway service has minimal configuration. Additional routing rules should be added based on requirements.

Config Server Configuration

Centralized configuration management. File: microservice-config/src/main/resources/application.properties
spring.application.name=microservice-config
The Config Server should be configured with a Git repository or file system location for centralized configurations.

Environment-Specific Configuration

Using Spring Profiles

Create environment-specific configuration files:
spring:
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: create-drop
  datasource:
    url: jdbc:postgresql://localhost:5432/orderdb

logging:
  level:
    root: DEBUG
Activate profiles:
java -jar order-service.jar --spring.profiles.active=dev

Actuator Configuration

All services include Spring Boot Actuator for monitoring and management.

Default Endpoints

EndpointURLDescription
Health/actuator/healthApplication health status
Info/actuator/infoApplication information
Metrics/actuator/metricsApplication metrics
Loggers/actuator/loggersLogger configuration

Enable All Actuator Endpoints

Add to application.yml:
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
In production, restrict actuator endpoints and enable security.

Logging Configuration

Configure Logging Levels

logging:
  level:
    root: INFO
    com.microservice: DEBUG
    org.springframework.web: DEBUG
    org.hibernate: INFO
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} - %msg%n"
  file:
    name: logs/application.log
    max-size: 10MB
    max-history: 30

Logback Configuration

Create logback-spring.xml in src/main/resources/:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>
  
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/application.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>logs/application-%d{yyyy-MM-dd}.log</fileNamePattern>
      <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>
  
  <root level="INFO">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="FILE" />
  </root>
</configuration>

Database Schema Management

Hibernate DDL Auto Options

ValueDescriptionUse Case
createDrop and recreate schemaDevelopment only
create-dropCreate on start, drop on stopTesting
updateUpdate schema to match entitiesDevelopment
validateValidate schema, no changesProduction
noneNo actionUse with Flyway/Liquibase
Never use create or create-drop in production as it will delete all data.

Using Flyway for Migrations

Add Flyway dependency:
<dependency>
  <groupId>org.flywaydb</groupId>
  <artifactId>flyway-core</artifactId>
</dependency>
Configure in application.yml:
spring:
  flyway:
    enabled: true
    baseline-on-migrate: true
    locations: classpath:db/migration
  jpa:
    hibernate:
      ddl-auto: validate

Security Configuration

Basic Authentication (Example)

Add Spring Security:
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>
Configure in application.yml:
spring:
  security:
    user:
      name: admin
      password: ${ADMIN_PASSWORD:changeme}

Configuration Best Practices

1

Use environment variables for secrets

Never commit passwords to version control:
spring:
  datasource:
    password: ${DB_PASSWORD:default_dev_password}
2

Externalize configuration

Use Config Server or environment variables:
export SPRING_DATASOURCE_PASSWORD=secure_password
java -jar service.jar
3

Use appropriate ddl-auto settings

  • Development: create-drop or update
  • Production: validate with migration tools
4

Enable health checks

Configure comprehensive health indicators:
management:
  health:
    db:
      enabled: true
    diskspace:
      enabled: true
5

Configure timeouts

Set appropriate connection and read timeouts:
spring:
  datasource:
    hikari:
      connection-timeout: 30000
      maximum-pool-size: 10
eureka:
  client:
    registry-fetch-interval-seconds: 30

Quick Reference

Service Ports

ServicePortURL
Eureka Server8761http://localhost:8761
Order Service8090http://localhost:8090
Tracking Service8091http://localhost:8091
Inventory Service9090http://localhost:9090
Config Server8888http://localhost:8888

Database Connections

DatabaseHostPortDatabaseUserPassword
PostgreSQLorder_db5432orderdbpostgrespassword
MySQLinventory_db3306inventorydbrootpassword
MongoDBtracking_db27017trakcingdbrootpassword

Configuration Files

ServiceConfiguration File
Eurekamicroservice-eureka/src/main/resources/application.yml
Ordermicroservice-order/src/main/resources/application.yml
Inventorymicroservice-inventory/src/main/resources/application.yml
Trackingmicroservice-tracking/src/main/resources/application.yml
Gatewaymicroservice-gateway/src/main/resources/application.properties
Configmicroservice-config/src/main/resources/application.properties

Next Steps

  • Explore API endpoints for each service
  • Set up monitoring with Actuator and Prometheus
  • Configure centralized logging
  • Implement security and authentication
  • Set up CI/CD pipelines

Build docs developers (and LLMs) love