Adding a RestController to hapi-fhir-jpaserver-starter?

272 views
Skip to first unread message

Sean McIlvenna

unread,
Nov 8, 2021, 4:00:20 PM11/8/21
to HAPI FHIR
Can anyone provide some Spring Boot expertise on how to add a RestController to the hapi-fhir-jpaserver-starter project?
I have a copy of the hapi-fhir-jpaserver-starter project, and need to add some custom functionality to it. Wanting to do that in a separate @RestController... But, can't figure out how to get Spring Boot to recognize the new @RestController and routes. Whenever I do a GET/POST/PUT to the @RestController, Spring just responds with 404.

James Agnew

unread,
Nov 8, 2021, 4:08:59 PM11/8/21
to Sean McIlvenna, HAPI FHIR
I'm not a boot expert, but I'd speculate you need to create a spring config class (annotated with both @Configuration and @EnableWebMvc) and then either register it in the "overlayRegistrationBean()" method, or duplicate that method. That config class should contain a bean definition for your controller.

On Mon, Nov 8, 2021 at 4:00 PM 'Sean McIlvenna' via HAPI FHIR <hapi...@googlegroups.com> wrote:
Can anyone provide some Spring Boot expertise on how to add a RestController to the hapi-fhir-jpaserver-starter project?
I have a copy of the hapi-fhir-jpaserver-starter project, and need to add some custom functionality to it. Wanting to do that in a separate @RestController... But, can't figure out how to get Spring Boot to recognize the new @RestController and routes. Whenever I do a GET/POST/PUT to the @RestController, Spring just responds with 404.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/f4f242c5-8d9f-441b-9c0c-5189c1ed452cn%40googlegroups.com.

Sean McIlvenna

unread,
Nov 8, 2021, 5:34:41 PM11/8/21
to HAPI FHIR
Thanks for responding James!
I figured out that my @RestController was being registered with SpringBoot, but the `overlayRegistrationBean()` route `registrationBean.addUrlMappings("/*");` was overriding it.
As soon as I removed `overlayRegistrationBean()` the @RestController worked as expected...
Any ideas on how to tell the overlay to ignore a route, like it does with "/fhir/*"?

Matteo Steccolini

unread,
Dec 14, 2023, 10:58:38 AM12/14/23
to HAPI FHIR
I know this is an old question, but it shouldn't hurt to note that this issue was solved just recently thanks to pull request https://github.com/hapifhir/hapi-fhir-jpaserver-starter/pull/620 (method overlayRegistrationBean gets deleted).

Dinesh Chanchalani

unread,
Nov 28, 2024, 8:26:59 PM11/28/24
to HAPI FHIR
Thanks, this was very helpful and removing the  overlayRegistrationBean method worked like a charm.
Reply all
Reply to author
Forward
0 new messages