Using Spring 2.x XML schemas without internet access

Whilst most of us develop on machines that have access to internet, the machines that we deploy our applications upon don’t always have external access, or at the very least they have restricted access. This can make deploying applications that use Spring that reference the 2.x Spring schemas in their xml contexts, a pain.

You can of course get a copy of the Spring schemas and reference them locally, but there is a simpler and easier way to do this that doesn’t require you to maintain copies of the schemas locally; you can reference the schemas in the classpath, as they are contained in the Spring Jars that you will need to deploy for your application.

All you need to do is amend the your Spring xml context file to use the following opening declaration:

<?xml version="1.0" encoding="UTF-8"?>
<beans xsi:schemaLocation=" classpath:org/springframework/beans/factory/xml/spring-beans-2.5.xsd" 

Now, not all the declarations are located in the same locations in the Spring Jars, so you will have to dig around for the other schemas, but they will be in the Jars that they are associated with.

Whilst this seems trivial now, before finding this resolution, it took me an age to get this working in an environment with no internet access, so I hope it helps others who are experiencing this problem. I found this resolution on a Spanish site that I can no longer find – it was about 12 pages deep in the Google results. So I hope others find this easier.