*********************************************************** *****
Chapter 1 Spring download and installation
Download Home http://www.springframework.org/download.html, or Directly Use the link address: http://voxel.dl.sourceForge.Net/SourceForge/SourceFramework/spring-framework 1.1.4-with-dependencies. zip
Spring's download package has two: Spring-framework 1.1.4-with-dependencies.zip and Spring-Framework 1.1.4.zip, the second link above is the former, suggesting that you also download the former, because the former More than the latter, some Spring to use third-party packages, such as Hibernate, J2EE, DOM4J, AOPALLIANCE, JAKARTA-COMMONS, etc. Dependencies downloading the name of the download package is "dependent".
1. The directory structure after decompression is as follows:
Directory Description:
l Dist Spring self-cultivation
l DOCS has some documentation.
l LIB is some third-party libraries for use.
l Mock imitation product? ? ? ? ? ? ? ? ? ? ? ? ? I do not know either
l Samples some project examples
l Src Spring source code
l Test test case
2, create a new Eclipse project
(1) My project name myspring
(2) Click "Next" directly, click Finish
(3) Create a lib directory under the project
(4) Copy Spring's decompression directory DIST and LIB to this lib directory, then the former is changed to Spring, the latter is temporarily moving, and it will be used in the future.
3, add the Spring library to the library reference
Access the Spring library into the library reference, there are two methods.
Method 1: Click Add JAR to join the Spring's core package.
Method 2: The above "method one" is simple and easy, but if a project is to be introduced, there is a lot of chaos. There is also a way to operate, but more clear methods. This method is to use the "user library" in Eclipse, as shown below:
The final result is shown below, and then click OK.
After returning the previous interface, click "Finish" to get the effect as shown below.
Finally, the reference to the Spring package in the project is in a directory, and the display hierarchy is much stronger.
If you want to introduce a third party package in the myspring / lib / lib directory, it is better to copy the Directory of the third party package to myspring / lib, and then refer to the method 2, add it to the library reference
4, set the library of log packs
JAKARTA-COMMONS and LOG4J packs are mainly used as Spring's runtime output log (log), if not set, then the log cannot be output to the console, which is not conducive to development and debugging. The setting method is as follows:
(1) Take the Log4j directory under the myspring / lib / lib directory and move the next layer to the myspring / lib directory. The result of the final setting is as shown in the following figure, here we move the log4j to the tahers directory, because log4j is a JAR package, specifically for it like Jakarta-Commons, and the user library is too worthless, there may be this in the future. When you quote a single package, you will be in the Others directory. (2) After the log's library bouting is complete, create a log configure file: log4j.properties, the contents of its files are as follows:
Log4j.rootlogger = debug, stdout
Log4j.appender.stdout = org.apache.log4j.consoleAppender
Log4j.Appender.stdout.Layout = Org.apache.log4j.patternlayout
Log4j.Appender.stdout.Layout.conversionPattern =% c {1} -% M% N
The creation location of the log4j.properties file In the src directory, as shown below:
If the log setting or setting is not set, the red word shown below occurs when using the console.
Java.lang.noclassdeffounderror: ORG / APACHE / COMMONS / Logging / LogFactory