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

Está retornado pagina não encontrada http://localhost:8080/hello

http://localhost:8080/hello

package br.com.alura.mvc.controller;

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

@Controller
public class HelloWordController {

    @GetMapping("/hello")
    public String helloWord() {

        return "hello";
    }
}
package br.com.alura.mvc.mundi;

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

@SpringBootApplication
public class MundiApplication {

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

}
`

src/main/resources/templates/hello.html

console

. __ _ __ _ _ /\ / _'_ _ _ _()_ _ __ _ \ \ \ ( ( )___ | ' | '| | ' / ` | \ \ \ \/ ___)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||_| |_, | / / / / =========||==============|__/=//// :: Spring Boot :: (v2.3.4.RELEASE)

2020-10-02 11:03:08.247 INFO 12720 --- [ restartedMain] br.com.alura.mvc.mundi.MundiApplication : Starting MundiApplication on NoteDeLLBruno with PID 12720 (C:\Users\bruno\Documents\CursoSpringMVC\mundi\target\classes started by bruno in C:\Users\bruno\Documents\CursoSpringMVC\mundi) 2020-10-02 11:03:08.250 INFO 12720 --- [ restartedMain] br.com.alura.mvc.mundi.MundiApplication : No active profile set, falling back to default profiles: default 2020-10-02 11:03:08.320 INFO 12720 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2020-10-02 11:03:08.321 INFO 12720 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2020-10-02 11:03:09.704 INFO 12720 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2020-10-02 11:03:09.715 INFO 12720 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2020-10-02 11:03:09.715 INFO 12720 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38] 2020-10-02 11:03:09.813 INFO 12720 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2020-10-02 11:03:09.813 INFO 12720 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1492 ms 2020-10-02 11:03:10.094 INFO 12720 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2020-10-02 11:03:10.437 INFO 12720 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2020-10-02 11:03:10.505 INFO 12720 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2020-10-02 11:03:10.527 INFO 12720 --- [ restartedMain] br.com.alura.mvc.mundi.MundiApplication : Started MundiApplication in 2.716 seconds (JVM running for 3.508)

2 respostas

Olá Bruno, tudo bem?

Então utilizando o SpringBoot todas as pastas tem que estar dentro do diretório mudi ( no caso tem que estar na mesma pasta que o arquivo de inicialização) pois é a partir de lá que o Spring vai começar a scannear os nosso arquivos

Então o seu HelloWorldController na verdade deveria estar no seguinte package:

package br.com.alura.mvc.mundi.controller;

Dessa forma temos a seguinte estrutura

  • MudiApplcation.java
    • controller
      • HelloWorldController.java

E o Spring consegue encontrar :)

Abraços e Bons Estudos!

solução!

Obrigado!!!! deu certo!!!!!