Utsav
Utsav

Reputation: 1603

How to use Spring Rest Service with REST Component in Mule

Hi I am working with Mule Studio and I want to use Spring Rest Service with REST component in the Mule. So how can I access Spring REST features with REST Component I don't want to use Jersey way of creating REST service with Mule.

I just want to declare one REST controller with spring annotation that will automatically invoke.

enter image description here

Upvotes: 2

Views: 731

Answers (1)

user1760178
user1760178

Reputation: 6697

Mules Rest Component is a Jersey implementation of JAX-RS which loads the resource classes so that they can be accesses as Rest URLs.

Spring Rest Controller is the Spring way of creating a Rest service which runs ona web-container. If you want to run the SpringRestController based rest service on Mule you can package and deploy it directly on Mule standalone. Mule can run a web applicaiton as it contains an embedded Jetty container.

Unfortunately you cannot include a Spring RestController into the Mules's REST component(which is a Jersey implementation). Controller's purpose is not to serve as a component.

By the way in Mule also you just need to specify the annotations and provide the resource class to the REST component. Mule takes care of the rest.

Hope this helps.

Upvotes: 2

Related Questions