0

I have this dilemma.

As from 2.14 version of GeoServer, there is a new way to write rest controller using @RestController annotation and extending RestBaseController.class

But after starting the server I can't see the custom rest path.

How do I create custom REST services with the new way?

  • why do you want to add new RESTControllers? – Ian Turton Nov 1 '18 at 15:57
  • To add functionality to ease tasks in our project. – DJColdBrain Nov 1 '18 at 16:03
1

So the answer to my question is this in the controller I have to Annotate it like this while extending RestBaseController.class

@RestController
@RequestMapping(RestBaseController.ROOT_PATH + "/test")
public class HelloController extends RestBaseController {

}

And in the applicationContext.xml I have to write this

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="<pakagesToScan>.*"/>

</beans>

And last but not least you have to Add your new module to the dependencies of GeoServer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.