Bom dia, Estou passando por um problema aparentemente sem explicação, ja verifiquei mil vezes, e minhas classes de configuração estão corretas como podem var abaixo:
Configurações do AppWebConfiguration
package br.com.casadocodigodois.conf;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import br.com.casadocodigodois.controller.HomeCDCController;
@Configuration
@EnableWebMvc
@ComponentScan(basePackageClasses = { HomeCDCController.class })
public class AppWebConfiguration {
@Bean
public InternalResourceViewResolver internalResourceViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
}
Configurações do Servlet do Spring
package br.com.casadocodigodois.conf;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class ServletConf extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
// TODO Auto-generated method stub
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { AppWebConfiguration.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
Controller do primeiro exercicio
package br.com.casadocodigodois.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeCDCController {
@RequestMapping("/")
public void index() {
System.out.println("acessado");
}
}
pom.xlm
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.casadocodigodois</groupId>
<artifactId>casadocodigodois</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>7.0.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jstl-impl</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<finalName>casadocodigodois</finalName>
</build>
<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>
</project>
o log de inicialização do servidor
mar 08, 2017 1:26:20 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:casadocodigodois' did not find a matching property.
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version: Apache Tomcat/7.0.75
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built: Jan 18 2017 20:54:42 UTC
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number: 7.0.75.0
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name: Windows 7
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version: 6.1
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture: amd64
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home: C:\Program Files\Java\jre1.8.0_121
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version: 1.8.0_121-b13
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor: Oracle Corporation
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE: C:\Users\Gouveia\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME: C:\Users\Gouveia\Desktop\Resources\apache-tomcat-7.0.75
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Users\Gouveia\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Users\Gouveia\Desktop\Resources\apache-tomcat-7.0.75
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Users\Gouveia\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Users\Gouveia\Desktop\Resources\apache-tomcat-7.0.75\endorsed
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252
mar 08, 2017 1:26:20 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_121\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Java\jdk1.8.0_121\bin;.
mar 08, 2017 1:26:20 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"]
mar 08, 2017 1:26:20 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-bio-8009"]
mar 08, 2017 1:26:20 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 503 ms
mar 08, 2017 1:26:20 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
mar 08, 2017 1:26:20 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.75
mar 08, 2017 1:26:21 PM org.apache.catalina.startup.TldConfig execute
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
mar 08, 2017 1:26:21 PM org.apache.catalina.core.ApplicationContext log
INFORMAÇÕES: No Spring WebApplicationInitializer types detected on classpath
mar 08, 2017 1:26:21 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"]
mar 08, 2017 1:26:21 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-bio-8009"]
mar 08, 2017 1:26:21 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 1013 ms
Sim meu home.jsp esta configurado dentro da pasta /WEB-INF/views/ conforme foi informado no Resolver.
realmenten sei onde esta o erro!
Obs: O mais curioso é que eu fiz esse curso ate o exercicio 8, dai resolvi começar um do zero para testar meus conhecimentos e configurar o projeto passo a passo de acordo com minhas anotações sem olhar no alura. O projeto que eu fiz até o exercicio 8 esta funcionando normalmente. so que esse novo projeto eu nao confisigo passar nem da primeira parte !!! isso é muito estranho !!! ja verifiquei tmbm passo a passo olhando no outro projeto que esta funcionando e esta tudo igual.