-2

In my application.properties I have defined port and server context.

server.port=8080
server.context-path=/SekcjaN

How to read value context to insert it into RequestMapping value in controller.

@RestController
@RequestMapping(value = server.context-path+"/auth")
public class AuthController extends BaseController {
}
maciejka
  • 818
  • 2
  • 17
  • 42
  • Try checking this [solution](https://stackoverflow.com/questions/30528255/how-to-access-a-value-defined-in-the-application-properties-file-in-spring-boot) – Mohale Apr 05 '18 at 19:50

2 Answers2

1

You don't need to add server.context-path into your controller RequestMapping as it is already handled by spring boot as base path. So if you are using server.context-path as something all your mapping will be prefixed with server.context-path value.

You can just use your code like this

server.port=8080
server.context-path=/SekcjaN

Controller file looks like

@RestController
@RequestMapping(value = "/auth")
public class AuthController extends BaseController {
}

Your code will perfectly be called by using <domain>:<port>/SekcjaN/auth/..

Samarth
  • 773
  • 1
  • 6
  • 14
0

You simply don't, it's already implied. The mappings are relative to the web application context path (to be precise: relative to the dispatcher servlet that is by default mapped on the root path within the application). server.context-path configures the path where the entire application is available within the server.

rainerfrey
  • 560
  • 4
  • 14