Spring JAR configuration
first I'd like to apologize, but I'm quite new to Spring, specially configuring projects from the beginning, so maybe this will be really trivial question.
I'd like to separate my data layer as a separate maven project and use it as a dependency in other web projects. I'd like to know how do I have to setup application context.xml, to load my Spring configuration, so that I'll be able to use this JAR just as a dependency in another project(s).
I know application context has to reside within classpath, so my resist in resources/META-INF together with persistance.xml file.
I'd be gratefull if somebody could let me know what are the next steps or point me to some good sample.
Another question is, what is the easiest way to unit test this application?
Thanks in advance.
You can separate projects and have your spring application-context.xml in the main project import the application context in the dependency as follows.
<?xml version="1.0" encoding="UTF-8"?>
In your build tool you can add the dependency in your config e.g. if you are using maven you can add it like ..
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
<import resource="classpath:spring/core-context.xml" />
As for your other question regarding Unit testing, there should be no change in the way you do unit tests. Unit test only test the particular unit of code and are not dependent on architctural changes. Integration test on the other hand would test the flow of the system. For that, you need to check the spring test framework.
Originally Posted by gregamb