One: quasi-work (download the required jar package)
1. Download Preparation spring-framework-4.2.0
Links to:
http://repo.springsource.org/libs-release-local/org/springframework/spring/
:
2. Specific spring-framework4.2.0
3. Download Log
Links to:
http://commons.apache.org/proper/commons-logging/download_logging.cgi
:
Two: Construction projects
1. Create a common Java project
2. Create a new Lib folder and copy and paste the jar package into
3. BUiD the Lib package to path
Then import the required jar from the firstspring
Then reply and OK
4. The effect at this time
5. New Package
Class Package:
XML Package
6. New Class
First interface
1 Package Main.java.com.sommer.learn; 2 3 Public Interface HelloWorld {4 Public 5 }
Implementation class
1 Package Main.java.com.sommer.learn; 2 3 Public class Implements helloworld{4 @Override5public String sayhi () { 6 return "Hahahahahha"; 7 }89 }
7. Create a new XML file
1 <?xml version= "1.0" encoding= "UTF-8"?>2 <beans3 xmlns= "/http/ Www.springframework.org/schema/beans " 4 xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance " 5 6 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">7 8 class= "Main.java.com.sommer.learn.HelloWorldImpl" ></bean>9
8. New Main function
1 PackageMain.java.com.sommer.learn;2 ImportOrg.springframework.context.ApplicationContext;3 ImportOrg.springframework.context.support.ClassPathXmlApplicationContext;4 5 Public classMain {6 Public Static voidMain (string[] args) {7ApplicationContext APC =NewClasspathxmlapplicationcontext ("Springxml/helloworld.xml"); 8HelloWorld Hello = Apc.getbean ("HelloWorld", HelloWorld.class); 9 System.out.println (Hello.sayhi ()); Ten } One}
9. Running
Create a new spring project from Eclipse