Olá! Na aula 2 removemos a requisição ao '/' para uma nova classe controller. Comigo simplesmente não funciona. Sempre tomo o erro abaixo:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Jan 12 16:27:30 BRST 2017
There was an unexpected error (type=Not Found, status=404).
No message available
Meu projeto até o momento está assim:
CONFIGURACAO.CLASS
package br.com.concrete.cantina.conf;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@EnableAutoConfiguration
public class Configuracao {
public static void main(String[] args) {
SpringApplication.run(Configuracao.class, args);
}
}
HOMECONTROLLER.CLASS
package br.com.concrete.cantina.conf;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String index(){
return "index";
}
}
POM.XML
<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>br.com.concrete.cantina</groupId>
<artifactId>cantina</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.4.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.4.3.RELEASE</version>
</dependency>
</dependencies>
</project>
INDEX.HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<title>Home</title>
</head>
<body>
<div class="container">
<div class="jumbotron" align="center" style="margin-top: 50px;">
<h1>Seja bem vindo ao ListaVIPs</h1>
<div align="center">
<a href="listavip" class="btn btn-lg btn-primary">Clique aqui para ver a lista de convidados</a>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
Log de start da aplicação:
SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.3.RELEASE)
2017-01-12 16:34:25.371 INFO 12737 --- [ main] b.c.concrete.cantina.conf.Configuracao : Starting Configuracao on CSRJL141L with PID 12737 (/home/josuefreitas/Projetos/Java/target/classes started by josuefreitas in /home/josuefreitas/Projetos/Java)
2017-01-12 16:34:25.375 INFO 12737 --- [ main] b.c.concrete.cantina.conf.Configuracao : No active profile set, falling back to default profiles: default
2017-01-12 16:34:25.758 INFO 12737 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@30ee2816: startup date [Thu Jan 12 16:34:25 BRST 2017]; root of context hierarchy
2017-01-12 16:34:27.489 INFO 12737 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-01-12 16:34:27.509 INFO 12737 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-01-12 16:34:27.510 INFO 12737 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-01-12 16:34:27.671 INFO 12737 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-01-12 16:34:27.672 INFO 12737 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1918 ms
2017-01-12 16:34:27.938 INFO 12737 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-01-12 16:34:27.942 INFO 12737 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-01-12 16:34:27.942 INFO 12737 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-01-12 16:34:27.942 INFO 12737 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-01-12 16:34:27.943 INFO 12737 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-01-12 16:34:28.381 INFO 12737 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@30ee2816: startup date [Thu Jan 12 16:34:25 BRST 2017]; root of context hierarchy
2017-01-12 16:34:28.479 INFO 12737 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-01-12 16:34:28.480 INFO 12737 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-01-12 16:34:28.517 INFO 12737 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-01-12 16:34:28.517 INFO 12737 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-01-12 16:34:28.554 INFO 12737 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-01-12 16:34:29.124 INFO 12737 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-01-12 16:34:29.193 INFO 12737 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-01-12 16:34:29.201 INFO 12737 --- [ main] b.c.concrete.cantina.conf.Configuracao : Started Configuracao in 4.363 seconds (JVM running for 4.711)