Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1.

How to do set up for Micro Services :

Configuration Server

1 Download erl and rabbitmq server.


2 Create a folder named as config-repo in user directory
3 Run following commands :
 git config –global user.email gsranish@gmail.com
 git config –global user.name “anishsri”
 git init
 echo message=helloworld>sample.properties
 git add –A
 git commit –m “Addingsample.properties”

******************************************************************************

2. Create a Spring Starter Project for “Configuration for Server “

1. named as “ConfigServer”

2. select “Config server “ and “Actuater” starters.

3. Goto src/main/resources folder, rename application.properties to bootstrap.properties. Change the


configuration in the config server to use Git repository created.

Like server.port=8888 (Default port of config server )

spring.cloud.config.server.git.uri: file://${user.home}/config-repo

management.security.enabled=false

4. Add @EnableConfigServer in application.java file in ConfigServer Project.

5. Run Config Server by right click on the project and Run as SpringBoot App.

6. Visit http://localhost:8888/actuator/env to see the server is running. If everything is fine.

7. Visit http://localhost:8888/sample/default/master to see the properties specific to sample.

8.

***********************************************************************************

Configuration Client

In this section all micro services will be modified to connect with config server. All our micro services will be act
as config clients.
1. Stop all micro services and add the spring cloud config dependency and the actuator ( if the actuator is
not already in place ) to the pom.xml

<dependency>

<group-Id>org.springframework.cloud</group-Id>

<artifact-Id>spring-cloud-starter-config</artifact-Id>

</dependency>

Since we are modifying the spring boot fares microservice from the earlier project. We will have to add
the following to include the spring cloud dependencies.

<dependencyManagement>

<dependency>

<group-Id>org.springframework</group-Id>

<artifact-Id>spring-cloud-dependencies</artifact-Id>

<version>Dalston.SR1</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencyManagement>

2 Rename application.properties as bootstrap.properties in src/main/resources folder

And add configuration server url. Also commit out configuration properties.

#src/main/resources/bootstrap.properties

Spring.appliaction.name=fares.service

Spring.cloud.config.uri=http://localhost:8888

#Move all below properties to fares-service.properties file into Git Repo

Spring.datasource.driver.class-name=oracle.jdbc.driver.OracleDriver

Spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl

Spring.datasource.username=fareuser

Spring.datasource.password=gsr123

Spring.jpa.prperties.hibernate.default_schema=FAREUSER

#Tomcat Settings
Spring.datasource.tomcat.initialSize=20

Spring.dataosurce.tomcat.max-active=25

Spring.jpa.hibernate.ddl-auto=create

Spring.jpa.show-sql=true

Management.security.enabled=false

*** Notes: The “ Fares-service “ is a logical name is given to the fares microservice. This will be treated
as a service ID.The config will look for fares-service.properties in the GIT repository to resolve the
properties.

3 Create a new fares-service.properties under the config-repo folder where the GIT repository was
created. Move service-specific.properties from bootstrap.properties to the new fares-
service.properties file.

# …/config-repo/fares-service.properties

Spring.datasource.driver.class-name=oracle.jdbc.driver.OracleDriver

Spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl

Spring.datasource.username=fareuser

Spring.datasource.password=gsr123

Spring.jpa.prperties.hibernate.default_schema=FAREUSER

#Tomcat Settings

Spring.datasource.tomcat.initialSize=20

Spring.dataosurce.tomcat.max-active=25

Spring.jpa.hibernate.ddl-auto=create

Spring.jpa.show-sql=true

Management.security.enabled=false

Add and commit all changes in the GIT repository.

git add –A

git commit –m “Adding fares-service.properties”

4. Type Config Server URL http://localhost:8888/fares-service/default/master to see the properties


specific to fares-service.properties, which were added in the earlier step.

5 Repeat all the above steps in search bookin, check-in-microservice and website.

6. Start all services and website,. Also perform booking and check-in through website using
http://localhost:8001

Username : gsr

Password : gsr123

You might also like