In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I remember when I first started learning frameworks, I thought that building frameworks was to add a plug-in somewhere in the compiler, (I thought Spring was a script or something, or an executable program. That is, with some foreign language software, if you want to have Chinese culture, you also need to add some Chinese plug-ins). Another misunderstanding is that the framework must be selected in the check box when creating a new project, or it will be troublesome or ineffective at all (I don't know where to turn my mind). Later, I built it several times and found that it was nothing more than the configuration file and jar (in maven, just write the configuration file correctly), which is not very simple. Let's go one step at a time.
First, configure pom.xml to introduce framework-related jar packages (before, when I taught myself to use Eclipse, I didn't know the good stuff like maven. Downloading jar packages everywhere is sometimes easy to be cheated, and version conflicts also occur from time to time. The worst time is when you have to go to your download directory to find the jar package you need to download, and you can't miss it.)
Add jar dependencies to pom.xml:
Spring-core: the core container that provides the basic functionality of the Spring framework. Spring organizes and manages components and their relationships in Java applications in the way of bean. Spring uses BeanFactory to generate and manage Bean, which is an implementation of the factory pattern "BeanFactory uses the inversion of Control pattern (IoC) to separate the application's configuration and dependency specification from the actual application code. BeanFactory provides dependencies to components using dependency injection.
The spring-web:Web context module is built on top of the application context module and provides context for Web-based applications. The Web layer uses the Web layer framework, which optionally can be Spring's own MVC framework or provided Web frameworks such as Struts, Webwork, tapestry, and jsf.
Spring-oxm:Spring integrates well with all the major ORM mapping frameworks, including Hibernate, JDO implementation, TopLink, and IBatis SQL Map. Spring provides helper classes such as templates for all of these frameworks and achieves a consistent programming style.
Spring-tx:spring provides support for transactions. The transaction processing and implementation classes are in this Jar package.
Simple encapsulation of jdbc by spring-jdbc:spring
The spring-webmvc:MVC framework is a full-featured MVC implementation for building Web applications. Through the policy interface, the MVC framework becomes highly configurable. Spring's MVC framework provides a clear division of roles: controllers, validators, command objects, form and model objects, dispensers, processor mappings, and view parsers. Spring supports a variety of view technologies.
The spring-context:Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, email, internationalization, checksum and scheduling capabilities.
Extended support for spring-context-support:spring-context for MVC aspects
The spring-aop:Spring AOP module integrates aspect-oriented programming functions directly into the Spring framework. Therefore, you can easily make any object managed by the Spring framework support AOP. The Spring AOP module provides transaction management services for objects in Spring-based applications. By using Spring AOP, you can integrate declarative transaction management into your application without relying on EJB components.
Spring-test:spring 's simple encapsulation of the JUnit framework.
For more information, please see this blog [the role of jar commonly used in Spring]: http://blog.csdn.net/gs932899178/article/details/53701503
So the packages for Spring and SpringMVC are imported.
Next, import Mybatis:
Database-related packages are also introduced:
To configure spring and springmvc, you must have the following configuration file: spring-mvc.xml:
It mainly includes annotating the configuration of the automatic scan package and starting the annotation function of SpringMVC, which can save a lot of writing of xml files.
Since the MVC schema is a model, view, and controller, views are also configured here, such as prefixes and suffixes.
To configure spring and mybatis, the following configuration files are available:
The configuration of adding automatic scan and loading properties is as follows:
Read the database configuration:
In fact, for each project, you can also subdivide these xml files into more:
For example, you can also configure automatic scanning of corresponding configuration files, such as BedMapper.xml, which correspond to
Some sql operations of the Bed entity.
So now look at the relationship between BedMapper and BedMapper.xml:
Configure transactions:
Next is the configuration of the web.xml file:
. Http://blog.csdn.net/gallenzhang/article/details/51932152 [SSM Framework Building]
In the src directory of java, create new folders such as entity, service, and controller,mapper, and create a new sqlmap in resources to create the mapper.xml file. In the mybatis-config.xml file, list all mapper and their paths.
Of course, to run, you have to read the configuration file: such as this class.
ClassPathXmlApplicationContext
To be continued.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.