Terminator Terminator - 28 days ago 12
Java Question

Spring boot mvc multimodule on Whitelabel Error Page

I know this question has been asked multiple times and i couldn't find an answer that fits.

Here i have created a maven multi-module project where in spring boot is included and i am not sure where have i gone wrong.

Someone please help me through,its been 2 days and cant find an answer.

BELOW IS THE ERROR I AM GETTING.

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Nov 08 17:22:26 IST 2016
There was an unexpected error (type=Not Found, status=404).
No message available


PARENT POM.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonic</groupId>
<artifactId>sonicboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>sonicweb</module>
</modules>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<start-class>com.sonic.applauncher</start-class>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>


MODULE POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sonic</groupId>
<artifactId>sonicboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>sonicweb</artifactId>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>


BottLauncherApp.java

package com.sonic.applauncher;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class BootLauncher {
public static void main(String[] args) throws Exception {
SpringApplication.run(BootLauncher.class, args);
}

}


PageController.java

package com.sonic.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PageController {
@RequestMapping("/index")
public String index(){
return "home";
}
}

Answer

Even i had the same issue.Just annotate with @ComponentScan("com.sonic").

This should work!!