Spring Development Environment Construction
Spring is a development framework that runs in a Java environment, so the following related software needs to be prepared before development:
1, JDK7 or above version
2, Eclipse4 or above version
3. Spring Framework Package 3 or 3 or later
Introduction to the Spring development package
When creating a spring project, it is necessary to introduce the spring development package, otherwise it will not be possible to establish the spring development and running environment, the following is a brief introduction of the following spring's core development package basic Purpose :
Spring Core
Spring Beans
Spring AOP
Spring Context
The following development package files are not spring core development packages, but offer a variety of enterprise-class services:
Spring Aspect
Spring Context Support
Spring Expression
Spring Framework Bom
Spring instrument
Spring Instrument Tomcat
Spring JDBC
Spring JMS
Spring ORM
Spring OXM
Spring Struts
Spring Test
Spring TX
Spring Web
Spring WEBMVC
Spring Webmvc Portlet
Create a sample project
The steps to create a spring IOC-based applet are as follows :
Set up Spring Engineering
Writing Java files
Writing a configuration file
Running an instance project
Set up Spring Engineering
First, we need to build a common Java project in Eclipse, and then introduce spring's core jar file into the project.
Writing Java files
here, we build the Java files one by one in the project:
Ihellomessage: An interface for defining output greeting information
Hellowold: An implementation class for an interface that outputs "Hello everybody" to the user
Hellochina: Interface implementation class, output "Everyone good" to the user
Person: A character class that invokes the Ihellomessage interface to output greeting messages to the user
Main: The entry class for the program, which loads the configuration file and launches the IOC container, invokes the character class, and outputs the greeting message to the user.
Writing configuration information
Next, create the configuration file Hellomessage.xml file for the sample code, as shown in the following example:
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE beans Public "-//spring/dtd bean/en" "Http://www.springframework.org/dtd/spring-beans.dtd" ><beans> <bean id= "HelloWorld" class= "Com.jike.spring.chapter01.HelloWorld" ></bean> <bean id= "Hellochina" class= "Com.jike.spring.chapter01.HelloChina" ></bean> <bean id= "person" class= " Com.jike.spring.chapter01.Person "> <property name=" hellomessage "ref=" Hellochina "/> </bean></b Eans>
Run the sample project
Compile and run the sample project, view the output information in the console, and run the program output correctly.
Spring Getting Started sample