From 2a54ea25d3e6ca8e468dcb30659a5813b54804b4 Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Mon, 13 Apr 2020 10:44:46 -0500 Subject: [PATCH] Change servlet context path. When applying `server.servlet.context-path=/ctx`, the links automatically adjust. ``` 2020-04-13 10:43:59.877 INFO 79416 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/ctx' ``` Testing with curl... ``` $ curl localhost:8080/ctx/employees | jq { "_embedded": { "employees": [ { "id": 1, "firstName": "Frodo", "lastName": "Baggins", "role": "ring bearer", "fullName": "Frodo Baggins", "_links": { "self": { "href": "http://localhost:8080/ctx/employees/1" }, "employees": { "href": "http://localhost:8080/ctx/employees" } } }, { "id": 2, "firstName": "Bilbo", "lastName": "Baggins", "role": "burglar", "fullName": "Bilbo Baggins", "_links": { "self": { "href": "http://localhost:8080/ctx/employees/2" }, "employees": { "href": "http://localhost:8080/ctx/employees" } } } ] }, "_links": { "self": { "href": "http://localhost:8080/ctx/employees" } } } ``` --- basics/src/main/resources/application.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 basics/src/main/resources/application.properties diff --git a/basics/src/main/resources/application.properties b/basics/src/main/resources/application.properties new file mode 100644 index 0000000..4692cf6 --- /dev/null +++ b/basics/src/main/resources/application.properties @@ -0,0 +1 @@ +server.servlet.context-path=/ctx