This guide describes how to set up a Spring Boot microservice and integrate it in the microservice system landscape.
Content
...
...
...
Table of Contents |
---|
Requirements
A basic understanding of building an application with Spring Boot and building Java projects with Maven is required.
...
Jolokia is an HTTP/JSON bridge for remote JMX access. This dependency is needed to be able to access a services's JMX beans from the admin-service user interface.
spring-cloud-starter-config
(https://cloud.spring.io/spring-cloud-config/)
...
The configuration parameter server.port
specifies at which port the service should be started (see also Overview of Microservices). The port is also used as spring.application.index
. The spring.application.name
is the service name with which it signs in to Discovery. If multiple services have the same name, the Discovery Service treats them as a service group, even if the instances are running on different hosts and ports. However, if you plan to have the same service running with different configurations for different applications in a system landscape, then these should have different names. One example would be to use the gateway service once with NTLM authentication and once with basic authentication.
Anchor | ||||
---|---|---|---|---|
|
Configuration Files
The two most important configuration files are bootstrap.yml
and application.yml
. In a service, both should be in the directory src/main/resources.
The main difference between the two is that the properties of bootstrap.yml
are loaded before those of application.yml
. Some properties must be available earlier, and are thus configured in bootstrap.yml
. An example is the spring.cloud.config
properties, as well as server.port
and spring.application.name
. For a service to be able to get its configuration from a config server, it must know where it can get this configuration before loading it. In other words, it must know where the config server is. In addition, the service must know its name, since the configuration files of format ${spring.application.name}-prod.yml
are loaded in addition to the profile configurations. For more information, see the spring cloud website.
...
- Jolokia
- Spring Cloud Config
- Spring Cloud Config - Client Side Usage
- Spring Cloud Netflix
- Spring Boot features - Profiles
- Service Registration and Discovery
- Spring Cloud Context: Application Context Services
...