Table of contents:
This repository is for a microservices-based Parcel Tracking System. It allows clients to add and track shipments using a unique number. The system integrates with various carriers to locate the specific shipment. It features storing tracking history in a local database and periodically checks for updates on saved shipments. The system offers search functionality across all shipment attributes and enables printing of the tracking history, with files being stored in a separate resource.
-
Add dependencies
implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.cloud:spring-cloud-starter-config") implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client") -
Add decorator on beans which will use config from config server:
@RefreshScope -
Add these properties to your service's properties file:
spring:
application:
name: TODO
cloud:
config:
discovery:
enabled: true
service-id: CONFIG-SERVER
config:
import: "optional:configserver:"
server:
port: TODO # used only for debug purposes as services discover themselves using service-discovery
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
instance:
preferIpAddress: true
management:
endpoints:
web:
exposure:
include: refresh-
Create config file in
configsinconfig-serverdirectory- use
application.ymlfor general configurations - create
{application name}.ymlfile for service specific configuration
- use
-
After changes make
POSTrequest for service which configs you want to refresh i.e.curl --location --request POST 'YOUR-SERVICE-URL/actuator/refresh'For example
http://localhost:8080/actuator/refresh. -
To use additional services use
@FeignClient(“service-name”)annotation. A good method for creating such Feign Clients is to create interfaces with @RequestMapping annotated methods and put them into a separate module. This way they can be shared between server and client. On the server-side, we can implement them as @Controller, and on the client-side, they can be extended and annotated as @FeignClient.
See Greeting Client in test service and Greeting Client in demoapp and implementation in DemoAppApplication
- Start service discovery
- (Optionally) Start config server
- Start your service and wait for registering