Start and Test our skeleton services

Code Dexterous
3 min readJul 11, 2020

Config Service

Started successfully on port 8012.

Eureka Service

Application started successfully then open link in browser.

Eureka Dashboard

Some may occur an issue that application started but 404 coming when visited dashboard then add below configuration to fix that.

  • spring.freemarker.template-loader-path=classpath:/templates/
  • spring.freemarker.prefer-file-system-access=false

This happens because of below reasons

  • Old cache or corrupted plugins caches
  • templates folder in bin
  • Themeleaf used in application because this dashboard is build using Freemarker.

Please refer for more.

Gateway Service

Application Started successfully

And also loading configuration from Config Service

It also registered with Eureka Service

User Service

Since we have used MongoDB, JPA dependencies but haven’t done any configuration related to that so this will no start. So we have two solutions for this either we remove dependencies or wee configure it.

Let try to configure database in our user service to fix the issue.

  • In our main class modify our SpringBootApplication annotation to SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })

This will tell that we are going to give Database Data source connectivity. And now file will be.

Add below configuration in application.properties. This is not good practice to add password like this we will use encryption but not right now.

spring.data.mongodb.authentication-database=admin

spring.data.mongodb.username=root

spring.data.mongodb.password=password

spring.data.mongodb.host=localhost

spring.data.mongodb.port=27017

spring.data.mongodb.database=microservice_dev

spring.jpa.properties.hibernate.show_sql=false

spring.jpa.properties.hibernate.use_sql_comments=false

spring.jpa.properties.hibernate.format_sql=true

spring.jpa.properties.hibernate.type=TRACE

spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy

spring.jpa.hibernate.ddl-auto=update

Now our application should be started and would be added in Eureka Service.

Since we haven’t configure port number and also configured how to register user-service so let start one more instance of user service to see how it looks.

Finally that’s it all four service are up and running properly.

We have two major things to be consider

  • We have to move some common configuration and specific configuration to be loaded from Config Service instead of application.properties of each application. By this way we will be able to manage most of the configuration at a single place and it will be get reflected to others.
  • Now whenever we do changes in Config Service then we have to restart our applications to reload the setting but this is not good for large infrastructure. So we have to use something to auto-reflect settings.

--

--

Code Dexterous

I am full stack developer. Works on different technology and lean to learn more.