The spring framework under the Eclipse IDE uses a simple instance
1 preparation
Java JDK installation.
Eclipse Software Installation.
Depending on the system installation version 32/64, select Eclipse IDE for Java developers to install online.
Spring Framework Download.
commons_logging Package Download
2 Configuration work
Right-click on the project bar, build path->config build Path Select Librarys, Add External jars Import the spring and commons_logging jar packages
3 Sample Programs
Create the COM.MANONGJC package under the SRC folder, creating the HelloWorld class and the Mainapp class separately in the package, with the following code:
HelloWorld class
Package COM.MANONGJC;
public class HelloWorld {
Private String message;
public void Setmessage (String message) {
this.message = message;
}
public void GetMessage () {
SYSTEM.OUT.PRINTLN ("Your message:" + message);
}
}
Mainapp class
Package COM.MANONGJC;
Import Org.springframework.context.ApplicationContext;
Import Org.springframework.context.support.ClassPathXmlApplicationContext;
public class Mainapp {
public static void Main (string[] args) {
ApplicationContext context =
New Classpathxmlapplicationcontext ("Beans.xml");
HelloWorld obj = (HelloWorld) context.getbean ("HelloWorld");
Obj.getmessage ();
}
}
Under the SRC folder, create the Beans.xml file with the following code:
<?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= "HelloWorld" class= "Com.manongjc.HelloWorld" >
<property name= "message" value= "Hello world!" />
</bean>
</beans>
Select Mainapp, click Run, you can see the output log in the console.
The spring framework under the Eclipse IDE uses a simple instance