First, let's take a look at how to create a Spring project in Eclipse. I would like to put the procedure step by step as follows. We assume that the project we're creating is a regular java project. There are some different ways to create a Spring project in Eclipse. You can create a Spring project by using an Eclipse plug-in for Spring, such as Sping IDE; and you can also use existing example codes as a template, and you can also do everything just from scratch. I believe the last one is always a good choice because people can really learn something from the procedure.
But as I am also a beginner for Spring, I decide to use the simplest way first of all. I first installed the Spring IDE for Eclipse, by the URL: http://springide.org/updatesite. Note that:
Don't try to install the "Spring IDE Dependencies (only for Eclipse 3.2.x)" from the "Dependency" category on Eclipse 3.3. This feature is intended only for Eclipse 3.2 and is to keep Spring IDE backward-compatible. You will not be able to continue with the installation if you select this feature on Eclipse 3.3
It seems taking a while to download all packages, since it's composed of many library files. In the end, I found it doesn't help much with the project construction, since it doesn't generate the configure XML file for you, doesn't add the necessary third-party libraries for you, ... It seems to do nothing for you! Not lucky! We must take the last choice anyway. Probably it's a better idea to start with walking instead of running.
Before starting, we need download some third-party libraries, which would be mentioned later during the construction.
- Open Eclipse.
- New a Java project.
- Compile "applicationContext.xml" file, a simple template can be like, (nice, the format is kept when I did C&P.)
- <?xml version="1.0"?>
<!-- The template of configuration file for Spring framework. @author Yan Qi, @date 20071224 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="test" class="">
<property name="">
<bean class=""/>
</property>
</bean>
</beans>
- Create source codes.
- Basically, at least two libraries are necessary, including spring.jar, commons-logging.jar. Add them in the lib path.
- One package as an example is below: http://ficsr.googlecode.com/files/LearningSpring.zip
That's it! I believe it's a good starting point to study Spring.
No comments:
Post a Comment