The first step is to create a dynamic Web project.
The second step, download the spring-related compression package, and unzip;:
spring-framework-3.0.2.release-dependencies.zip: http://yunpan.cn/ccFvNrZAMCzqj access Password 3dbf (Spring's dependency package)
spring-framework-3.0.6.release-with-docs.zip: Http://yunpan.cn/ccFviEbKbgCrV access Password b510 (Spring's base package)
Download and unzip as shown in:
The third step, to the project, the introduction of the relevant jar package;
The list of jar packages to be introduced and the directory in which they are located, as shown in:
Spring Base jar Package
Log jar Package:
Into the project's Lib directory, as shown in:
At this point, the spring environment has been built.
Write a simple test program below to verify the availability of the environment.
The first step is to create a new User.java, as shown in:
User.java in the source code, as follows:
Package Com.cvicse.utmp.user;public class User {private int id;private String name;private int age;public int getId () {RET Urn ID;} public void setId (int id) {this.id = ID;} Public String GetName () {return name;} public void SetName (String name) {this.name = name;} public int getage () {return age;} public void Setage (int.) {this.age = age;} @Overridepublic String toString () {return "User [id=" + ID + ", name=" + name + ", age=" + Age + "]";}}
The second step, in the SRC directory, creates a new Spring.xml file, as shown in:
The source code in Spring.xml is as follows:
<?xml version= "1.0" encoding= "UTF-8"? ><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-3.0.xsd "><bean id=" user "class=" Com.cvicse.utmp.user.User "><property name=" id "value=" 1 "></property><property name=" name "value= "Xiaowei" ></property><property name= "Age" value= "></property></bean></beans>"
The third step is to build the test class, and the test code looks like this:
Package Com.cvicse.utmp.user;import Org.springframework.context.applicationcontext;import Org.springframework.context.support.classpathxmlapplicationcontext;public class TestUser {public static void main ( String[] args) {ApplicationContext apx = new Classpathxmlapplicationcontext ("Spring.xml"); User user = (user) Apx.getbean ("User"); SYSTEM.OUT.PRINTLN (user);}}
Run the results as shown in:
At this point, the environment has been set up, simple test completed.
Spring Environment Construction