This paper introduces the architecture, installation and configuration of Java spring framework

Architecture spring has the potential to become a one-stop service for all enterprise applications. However, spring is modular, allowing you to choose which modules are applicable without having to introduce them in the rest. The following sections detail all the modules available in the spring framework.

The spring framework provides about 20 modules that can be used according to the requirements of the application.

Core container: the core, beans, context and expression language module composed of the core container. The details are as follows:

The core module provides the basic components of the framework, including IOC and dependency injection.

Bean module provides beanfactory, which is a classic implementation of factory pattern.

The context module is built on a solid foundation provided by the core and bean class modules. It is the medium to access any object defined and configured. The ApplicationContext interface is the focus of the context module

The expression language module provides a powerful expression language for querying and manipulating object graphs at run time.

Data access / integration: the data access / integration layer includes JDBC, ORM, oxm, JMS and transaction processing modules. The details are as follows:

The JDBC module provides an abstraction layer related to JDBC that no longer requires lengthy JDBC coding.

Integration layer provided by ORM module. Popular object relational mapping APIs include JPA, JDO, hibernate and ibatis.

The oxm module provides an abstraction layer that supports object / XML Mapping, JAXB, castor, xmlbeans, jibx and xStream.

The JMS module of Java message service contains information for production and consumption.

The transaction module supports programming and declarative transaction management, implements special interface classes, and supports all POJOs.

Web: the web layer includes network, web servlet, web struts and portlet components of the network. The details are as follows:

The web module provides basic integration features of web development, such as multi-party file upload function, IOC container initialization of servlet listener and application context for web.

The web servlet module contains spring's model view controller (MVC) to implement web applications.

The web struts module contains spring applications within support classes and integrates the classic struts web layer.

The web portlet module provides the function of MVC to use and mirror the servlet module of the web in the portlet environment.

Others: there are other important modules such as AOP, aspect, specification, network and test modules. The details are as follows:

The AOP module provides an aspect oriented programming implementation that allows you to define method interceptors and pointcuts to clean and decouple the functions implemented and the code that should be separated.

The aspects module provides integration with AspectJ, which is a powerful and mature aspect oriented programming (AOP) framework.

The instrumentation module provides the support of class tools and class loader implementation in a certain application server.

The test module supports the testing of spring components using JUnit or TestNG framework.

Installing and configuring this tutorial will guide you through how to prepare your development environment and work with the spring framework. This tutorial will also teach you how to install JDK, Tomcat and eclipse. Before installing the spring framework:

Step 1 - install java development kit (JDK): javase Download: you can download the latest version of SDK from Oracle's Java website. You will find that the instructions teach you how to install JDK in the downloaded file. Follow the instructions to install and configure settings. Finally, set path and Java_ The home environment variable points to Java and javac, usually Java respectively_ install_ Dir / bin and Java_ install_ Dir directory.

If you are running Windows and have JDK installed, it is in C: jdk1 6.0_ 15. You can write the following line to C: Autoexec Bat file

In addition, on Windows NT / 2000 / XP, you can also right-click My computer, select properties, then advanced, and then environment variables. Then update the path value and press the OK button.

On UNIX (Solaris, Linux, etc.), if the SDK is installed in / usr / local / jdk1 6.0_ If you are using a C shell, simply write the following Cshrc file.

In addition, if you use an integrated development environment (IDE), such as JBuilder, eclipse, IntelliJ idea or sun one studio of Borland company, compile and run a simple program to confirm that the IDE knows how to install Java, otherwise you should make appropriate settings.

Step 2 - install the Apache common logging API: you can download the latest version of the Apache common logging API here http://commons.apache.org/logging/. Once downloaded and installed, unzip the binaries and distribute them to a convenient location. For example, in C: commons-logging-1.1 1. On Linux / Unix, / usr / local / commons-logging-1.1 1。 The directory will have the following jar files and other supporting files.

Please ensure that the classpath variable is set correctly on this directory, otherwise you will face problems when running the application.

Step 3 - install the eclipse integrated development environment. All examples in this tutorial use the eclipse ide. So I suggest you have the latest version of eclipse installed on your machine.

Install the eclipse ide from the latest eclipse binaries http://www.eclipse.org/downloads/. Once downloaded and installed, unzip the binary to a convenient location. For example, in C: eclipse or / usr / local / eclipse, set the path variable appropriately at the end of Linux / Unix.

Eclipse can be started by executing the following command on a Windows machine, or you can simply double-click eclipse exe

Eclipse can be started by executing the following commands on UNIX (Solaris, Linux, etc.):

After successful startup, if everything is normal, it should display the following results:

Step 4 - install the spring framework library. Now, if everything is normal, you can continue to set up the spring framework. The following are simple steps to download and install the framework on the machine.

Select whether to install spring on windows or UNIX, and then proceed to the next step. The downloaded zip file is applicable to windows and UNIX TZ file.

The latest version of the spring framework binaries downloaded from http://www.springsource.org/download.

While writing this tutorial, I downloaded spring-framework-3.1 0.M2. Zip in windows, when extracting the downloaded file, its directory structure is: C: spring-framework-3.1 0.m2 is as follows.

You will find all spring libraries in the directory C: spring-framework-3.1 0.M2dist。 Please ensure that the classpath variable is set correctly on this directory, otherwise you will face problems when running the application. If you are using eclipse, you do not need to set classpath, because all the settings will be done in eclipse.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>