How to add a custom REST(ish) endpoint to HAPI FHIR JPA Server

Hi all,

I am trying to build a little FHIR Server for special purposes (not meant to run in production or anything), and I’d like to augment the Server with a couple of additional utility REST API methods. These don’t need to be FHIR conform, so I am talking about a separate API that should be deployed as part of the same application.

I use HAPI FHIR JPA starter as a base, and while the non-API part works fine (injecting services, …) in the backend, I cannot get the API resource published as HTTP endpoint.

I guess I am almost there, but a certain piece is missing that probably is just Spring boot config stuff. Perhaps a HAPI FHIR dev is here to help?

What I did:

  • Added a method @Bean ServletRegistrationBean<DispatcherServlet> customApiRegistrationBean() to that creates DispatcherServlet with a custom Spring context bootstrapped from my class
  • The is annotated with @ComponentScan
  • My CustomAPIResource in the same package is annotated with @RestController
  • That class has a method @GetMapping(path = "/management/duStuff") public String doStuff()

The API resource is picked up by Spring Boot and properly initialized, but I never get the method to be called by for instance curl http://localhost:8080/management/doStuff. “No mapping for GET /management/doStuff” is all I find in the logs.

Any help would be appreciated, thanks

For HAPI-FHIR specific questions, you might also want to reach out to the folks at