Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Só consigo acessar um único mapeamento (index) o resto falha

Tenho (1) a seguinte SpringBootApp:

@SpringBootApplication
public class ListaVipApplication {

    public static void main(String[] args) {
        SpringApplication.run(ListaVipApplication.class, args);
    }
}

(2) o seguinte controlador:

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class StaticSitePagesController {

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

}

E (3) a página HTML, nome do arquivo home.html, criado no path: src/main/resources/templates/home.html.

Porque quando a aplicação sobre e eu digito a URL "http://localhost:8080/home" recebo o seguinte erro:

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Mon Apr 13 18:05:27 BRT 2020 There was an unexpected error (type=Not Found, status=404). No message available

3 respostas

Pode ser útil, meu 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.alura.com</groupId>
    <artifactId>listavip</artifactId>
    <version>1.0.0</version>

    <properties>
        <spring-boot-version>2.2.6.RELEASE</spring-boot-version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring-boot-version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>${spring-boot-version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>${spring-boot-version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.19</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${spring-boot-version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</project>
solução!

Oi Carlos

Em quais packages estão o ListaVipApplication e StaticSitePagesController ? Verifique se StaticSitePagesController está em um subpackage de ListaVipApplication

Foi exatamente isto. Coloquei pra cima, tudo funcionou! kkkkkkkk! Obrigado, não havia percebido este detalhe...

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software