3
respostas

Erro ao inicializar o spring

Está ocorrendo o seguinte erro ao executar o projeto...

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:186)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:575)
3 respostas

Olá Isaque Saraiva , você pode verificar se existe outro servlet(classes Java) registrado com o mesmo nome.

pode está ocorrendo um erro com a anotação @RequestMapping ,

@Controller
public class IndexController {

    @RequestMapping("/")
    public String index() {
        return "index";
    }
}
@EnableWebMvc
@ComponentScan(basePackageClasses = IndexController.class)
public class App {

    @Bean
    public InternalResourceViewResolver internalResourceViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }
}
public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[] {App.class};
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/" };
    }

}