简体   繁体   中英

SpringMVC Error

I have some problems in spring MVC Web

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Volumes/Data/Obasy/Computer Science/Java projects/Netbeans/WEB APPS/SpringMVCFrom/build/web/WEB-INF/classes/com/tutorialspoint/HelloWorldController.class]; nested exception is java.lang.IncompatibleClassChangeError: org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor

java.lang.IncompatibleClassChangeError: org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor

Check if HelloWorldController.class with annotation. For example:

@Component
public class HelloWorldController(){
 ...
}

And check in your context file, if the back-package includes the class

<context:component-scan base-package="xxx.xxx.xxx" />

And recompile your project and try again.

Please post your config files. Otherwise its hard to determine what exactly caused the problem.

A controller class should be annotated with @Controller, like this

@Controller
public class HelloWorldController() {
 ...
}

and the Spring MVC config should have a component scan either through XML

<context:component-scan base-package="package.of.helloworldcontroller" />

or through Java config

@Config
@ComponentScan(basePackage = {"package.of.helloworldcontroller"})
@EnableWebMvc
public class WebMvcConfig extends ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM