if i call the default url for my tomcat server, i will see an error 404. The program is running without any problems, but perhaps the restcontroller is disabled (i don't known, normally not). There are no erros in the log. The start page is a html-format. I set the default path (see below).
Im using Spring Boot and tomcat7.
The requested resource (/dashboard/) is not available.
Spring Boot path src\main\resources\templates\index.html
Index.html path in war: ..\tomcat7\webapps\dashboard\WEB-INF\classes\templates\index.html
Main
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = "com.###.dashboard")
@EnableJpaRepositories
@EntityScan(basePackages = "com.###.dashboard.domain")
public class Dashboard extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(new Object[] {Dashboard.class, DashboardController.class}, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Dashboard.class);
}
}
RestController
@RestController
public class DashboardController {
/**
*...
*/
@RequestMapping("/")
public String setPage(Model model) {
// ...
return "index";
}
}
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.###.dashboard</groupId>
<artifactId>Dashboard</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Dashboard</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.8.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mobile</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<start-class>com.###.dashboard.main.Dashboard</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
tomcat7 server
2014-12-05 13:31:46.836 INFO 28052 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[],param
s=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.###.dashboard.domain.DashboardController.setPage(org.springframework.ui.Model)
Thank you