2
respostas

Não consigo resolver o Whitelabel Error Page

Alguém que tenha conseguido resolver o whitelabel error page pode indicar a solução. Estou no começo do curso Spring MVC e segui o projeto tal qual o professor indica, ja reinstalei outras versões do Java, mas nada parece ajudar, vi que algumas pessoas conseguiram solucionar, mas não encontrei a possível solução. Pelo que eu entendi, me corrijam se eu estiver errado, o TomCat, não conseguiu mapear a aplicação. Em alguns fóruns um pessoal diz que o problema é na classe servlet, contudo sequer foi criado uma classe servlet... =/

Print de tela apresentando o erro "Whitelabel Error Page"

o código da aplicação é este. Print do Código fonte da classe Application desenvolvida no Eclipse IDE

E esta é a classe controller da aplicação Print do código fonte da classe Controller desenvolvida no Eclipse IDE

2 respostas

Observei também que no console ao rodar a aplicação ele diz que não encontrou o caminho do template e pede pra checar as configurações do Thymeleaf

Print de código fonte exiibindo a mensagem do console

. __ _ __ _ _ /\ / _'_ _ _ _()_ _ __ _ \ \ \ ( ( )___ | ' | '| | ' / ` | \ \ \ \/ ___)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||_| |_, | / / / / =========||==============|__/=//// :: Spring Boot :: (v3.0.3)

2023-02-25T21:12:34.203-03:00 INFO 7628 --- [ restartedMain] br.com.guedes.mvc.mudi.MudiApplication : Starting MudiApplication using Java 17.0.6 with PID 7628 (C:\Users\leand\eclipse-workspace\Spring MVC crie um web app com Thymeleaf e Bootstrap workspace\mudi\target\classes started by leand in C:\Users\leand\eclipse-workspace\Spring MVC crie um web app com Thymeleaf e Bootstrap workspace\mudi) 2023-02-25T21:12:34.212-03:00 INFO 7628 --- [ restartedMain] br.com.guedes.mvc.mudi.MudiApplication : No active profile set, falling back to 1 default profile: "default" 2023-02-25T21:12:34.297-03:00 INFO 7628 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2023-02-25T21:12:34.297-03:00 INFO 7628 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2023-02-25T21:12:35.945-03:00 INFO 7628 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2023-02-25T21:12:35.960-03:00 INFO 7628 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2023-02-25T21:12:35.961-03:00 INFO 7628 --- [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.5] 2023-02-25T21:12:36.061-03:00 INFO 7628 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2023-02-25T21:12:36.067-03:00 INFO 7628 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1767 ms 2023-02-25T21:12:36.530-03:00 WARN 7628 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Thymeleaf configuration, or set spring.thymeleaf.check-template-location=false) 2023-02-25T21:12:36.595-03:00 INFO 7628 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2023-02-25T21:12:36.637-03:00 INFO 7628 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2023-02-25T21:12:36.658-03:00 INFO 7628 --- [ restartedMain] br.com.guedes.mvc.mudi.MudiApplication : Started MudiApplication in 2.904 seconds (process running for 3.439) This is my 1st HW using SpringBoot Framework, I'm so excited!!!

Boa Tarde Leandro, tudo certo?

Pode compartilhar teu pom.xml, fiz um teste e deu certo.

@Controller
public class Hello {
    @GetMapping("/hello")
    public String getHello(){
        return "index";
    }    
}

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Olá</h1>    
</body>
</html>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>br.com.exemplo</groupId>
    <artifactId>exemplo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>exemplo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

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

    </dependencies>

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

</project>

img Insira aqui a descrição dessa imagem para ajudar na acessibilidade