Mathias Hauser

My opinions and thoughts on various things and experiences of software development

Monthly Archives: October 2016

Spring RestController specific basePath

I recently started taking a look into Angular 2 and though about a proper project setup in combination with Spring RestControllers. During development, the front-end Angular 2 application will run via Webpack and the Spring Boot application with an embedded Tomcat. All RestController should use a common base path, since I plan to run the Angular 2 application together with the Spring application in a production environment. The test scenario is a simple index.html file that should be hosted in the URL ‘/index.html’ and RestController hosted in ‘/api/hello’

Expected URL structure

/index.html – angular app placeholder
/api/hello – Endpoint for a rest controller

I recommend downloading the source of this example before you start. Link to the repository blog_rest-controller-base-path direct link to the source zip source-zip

Content of this post

  • Spring configuration for the base path of all RestControllers
  • Custom annotation that combines @RestController and @RequestMapping

Read more of this post

Advertisements