Rectangle 27 0

java Error when adding mvc:annotation driven in applicationContext.xml?


If you truly want to use Java Configuration to setup the Spring MVC components you must move all of the Spring MVC components established in the applicationContext.xml file to a Java class annotated with @Configuration and translate the XML beans to their appropriate configurations in Java.

In the web.xml file you are specifying that Java configuration will be used to setup the MVC components, however the MVC components are attempted to be setup within the applicationContext.xml file.

Thanks @KenvinBowersox. The real problem was the fact that I was mixing xml configuration with java configuration. I had some classes annotated with "@Configuration". Removing these classes resolved my problems.

The ContextLoaderListener in web.xml is setup to launch the /WEB-INF/applicationContext.xml configuration file. The container setup by applicationContext.xml should not include the MVC components but should be used for registering beans outside of the MVC scope such as those for data persistence.

Note
Rectangle 27 0

java Error when adding mvc:annotation driven in applicationContext.xml?


If you truly want to use Java Configuration to setup the Spring MVC components you must move all of the Spring MVC components established in the applicationContext.xml file to a Java class annotated with @Configuration and translate the XML beans to their appropriate configurations in Java.

In the web.xml file you are specifying that Java configuration will be used to setup the MVC components, however the MVC components are attempted to be setup within the applicationContext.xml file.

Thanks @KenvinBowersox. The real problem was the fact that I was mixing xml configuration with java configuration. I had some classes annotated with "@Configuration". Removing these classes resolved my problems.

The ContextLoaderListener in web.xml is setup to launch the /WEB-INF/applicationContext.xml configuration file. The container setup by applicationContext.xml should not include the MVC components but should be used for registering beans outside of the MVC scope such as those for data persistence.

Note