So, now you need to download individual spring component jars from the Maven Repository. The jars required are:
- spring-aop.jar
- spring-beans.jar
- spring-context.jar
- spring-core.jar
- spring-expression.jar
- aopalliance-1.0.jar - third-party jar
You can download the corresponding javadoc and source files by going to the Maven website and searching for:
- g:"org.springframework" AND v:"4.1.6.RELEASE" - for Spring components
- g:"aopalliance" - for aopalliance
Now that all the required jars are downloaded, spring-core jar will need to be included in most projects; here is a simple guide to when to include rest of the jars.
Add spring-beans.jar to classpath when you see the below or similar error during compilation:
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.NoSuchBeanDefinitionException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Add spring-context.jar to classpath when you see the below or similar error during compilation:
Caused by: java.lang.ClassNotFoundException: org.springframework.context.access.ContextSingletonBeanFactoryLocator
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Add spring-expression.jar to classpath when you see the below or similar error during compilation:
Caused by: java.lang.ClassNotFoundException: org.springframework.expression.ParserContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Add spring-aop.jar to classpath when you see the below or similar error during compilation:
The type org.springframework.aop.TargetSource cannot be resolved. It is indirectly referenced from required .class files
OR
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.framework.ProxyFactoryBean
Add aopalliance-1.0.jar to classpath when you see the below or similar error during compilation:
The type org.aopalliance.aop.Advice cannot be resolved. It is indirectly referenced from required .class files
OR
Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor
That's it - you should be all set and upgraded to the latest version of Spring after this exercise - no code change required!