Spring RestTemplate: URI is not absolute

You cannot do it as your code in the first snippet; the URI must FULLY identify the resource you are trying to get to. Your second snippet is the pretty much the only way you can do what you're trying to do. There may be other ways, but I can't think of any off the top of my head.

Of course, with your approach, you are dictating your system architecture and deployment model in code, which is almost never a good idea.


Your URL app2/myservice?par=1 is not complete if your service running on another web app or the same server.

You have to complete the path by giving base URL means localhost:8080/yourApp/app2/myservice?par=1 then the things might work for you.

Also, check the Package access.

Tags:

Java

Uri

Spring