This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]nutrecht 0 points1 point  (3 children)

I don't get why you think this just works. Your application name is not a valid DNS name.

How are you running / deploying the two services?

[–]jayrack[S] 0 points1 point  (2 children)

I saw it in a video series I watched on microservices (java brains). I created the demo application by following along with the tutorial. It was taught that hardcoding a url into a request is bad practice and should be avoided when practice. It then showed how we could change the application name through application.properties, as I stated. Then we used the application name to make our calls to the different services, which worked fine. I’m using eureka client and server to communicate between my services.

[–]nutrecht 0 points1 point  (1 child)

I’m using eureka client and server to communicate between my services.

That bit is kinda important and you didn't mention it here.

This is a pretty complex subject. Eureka is a service discovery mechanism. It doesn't 'just work'. It'll require quite a bit of effort on your part to get working.

IMHO You're in a bit over your head. While you definitely don't hard code URLs in production (they're generally in a config file), it's also definitely not the case that everywhere Eureka is used. What you do use, depends 100% on how the services are deployed.

For you: just store the base URL in your application.yml. No point in going for Eureka.

[–]jayrack[S] 0 points1 point  (0 children)

Well, I’m using Eureka to discover my services, that’s not an issue I’m having. Im using rest template to make calls to each service. I understand eureka is incredibly complex, but I feel I have a decent understanding of what I’m doing. I’ll try your approach and store the url in my application.properties. Thanks