Spring Boot alternative index page
configuration, java, spring, spring-boot, spring-mvc
Solution
Going by the common Spring Boot properties, you should be able to modify this property:
spring.application.index=
Admittedly, I do tend to create a minimal 'home' controller with a `@RequestMapping("/")` anyway. :)
It's worth noting that the `build` directory will only be on the classpath if it's under `src/main/resources`. It's also worth mentioning that the contents of `src/main/webapp` don't get bundled into the jar automatically. `src/main/resources/static` is where Spring Boot will look for your static web files. As such, there are a couple of alternatives for you.
Option 1: Configure your Grunt build to output to a directory under `src/main/resources/static`.
Option 2: Configure your Java build tool to take the Grunt output and put it in your resources directory, so that it's on the classpath. For example, using Maven, the following would move the contents of a directory called `build` into your `src/main/rescources/static`.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
<resources>
<resource>
<directory>build</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Problem
My app uses Spring Boot on the back end and a SPA (Angular) site on the front end. Currently I am serving the index.html page from the `webapp` folder, which works automatically no configuration needed. Now I integrated a build process for the front end using gulp and all the created sources are "copied" into a `build` directory. Now I would like to serve the `index.html` file from the `build` directory as my main page. I tried `spring.application.index=build/index.html`and some other spring boot settings, but nothing worked. I believe no code is needed from my current code base but if anything is missing let me know. Is there a way to configure this in the `applications.properties` file? Do I need to create a controller for the index page? Or is there any other way to change the default behavior? thanks