Social Media

Spring Configuration – Version Numbers in Schema Locations

I recently had the following compilation issue –

The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'.

The issue was due to conflicting spring schema locations due to the use of version numbers in the schema’s. The suggested best practice is to remove the version numbers –

xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

Would become –

xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

The reasoning being that spring will seek the highest versions of the schema that it can find in the Jars, and you don’t have to maintain the versioning in your configuration files. This can then be controlled using your maven pom, or build process

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: