For the programming idea of AOP, many frameworks have been implemented. Spring is one of them and can be done with aspect-oriented programming. However, AspectJ also implements the functionality of AOP and is simpler to implement, easier to use, and supports annotated development. Therefore, spring also introduces AspectJ's implementation of AOP into its own framework.When using AOP development in
object that is enhanced by the AOP framework, also known as an enhanced object. If the AOP framework is implemented through a runtime proxy, then the object is a Proxied object.3, AOP Proxy: The object created by the AOP framework, simply put, the agent is the enhancement of the target object.4, Weaving (Weaving): Add enhanced processing to the target object, and create an enhanced processing process is to weave in.2, Spring's AOP supportIn AOP programming, we need to do the following three par
Spring,mybatis Transaction Management configuration and @transactional annotation usageOverviewTransaction management is critical for enterprise applications, and it guarantees data consistency even in the event of an exception.The Spring framework provides a consistent abstraction of transaction management, with the following characteristics:
Provides a
data Access Components, DAO components@Controller for labeling control-level components, such as action in struts@Component A generic component, you can use this annotation to annotate a component when it is not well categorized1, you can use such as @service ("Persondao") to modify the bean name, and it defaults to the first letter lowercase class name 2. To change the
Generally use @resource annotations
*/ Public StaticApplicationContext Getapplicationcontext () {returnAppctx; } /*** TODO: This is a convenient way to help us get a bean quickly * @Auhor: RICK * @Date: November 1, 2016*/ Public StaticObject Getbean (String beanname) {returnAppctx.getbean (beanname); }}2. Add in the spring configuration file. xmlclass= "Com.haier.util.SpringBeanFactoryUtils"/>3. Use service in Ordinary classZpaccou
Recent projects are using the Springmvc+spring+mybatis framework to find a transaction that cannot be rolled back when the transaction is configured.The first configuration is as follows: Springmvc.xml configuration content:Spring.xml Configuration ContentAs seen from the above two profiles, I started by configuring the service in SPRINGMVC. However, the transaction annotations I configured in
Using annotations to implement spring's declarative transaction management is even easier!Steps:1) An AOP-related jar file must be introduced2) Transaction manager class for declarative transaction management and application in Bean.xml specified annotation mode3) in the place where you need to add transaction control, write: @Transactional@Transactional notes:1) Annotations for application transactions2) Definition to method: The current method appli
1. Common annotations in Spring Bean Management@Component: Components . ( acting on the class )Public interface Userdao {public void SayHello (),} @Component (value= "Userdao") public class Userdaoimpl implements Userdao {@Overridepublic void SayHello () {System.out.println ("Hello Spring Annotation ...");}The three derivative annotations provided @Component in
Use spring AOP and annotation implementation methods to check the cache-How far can we go series (46), aopcache-
Subject:This code is a common code used in development. It queries the data of a master table in a database. To improve performance, a cache is performed. cache data is obtained for each call, and data is directly returned, no data can be queried from the database to reduce the pressure on the da
1. Use @ autowired for automatic Injection
Spring uses the @ autowired annotation to implement bean dependency injection. Let's look at an example:
1. Inject class attributes
package spring.ioc.autowired;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier;import spring.ioc.demo1.Car;public class UseAutoWired { @Autowired @Qua
dynamic Proxy to create an AOP proxy by default, so that you can create proxies for any interface instances.Spring can also use the Cglib proxy, which automatically switches to use the Cglib proxy when a proxy class is required instead of a proxy interface.Spring currently supports only method calls as Connection points (Joinpoint), and if you need to add access and updates to the field as a connection point for enhanced processing, you might consider using ASPECTJ.Throughout AOP programming, t
")@javax. annotation.postconstruct
The initialization action that spring performs when the instance is created.
Location: Using the method level
Parameters: None@javax. Annotation.predestroy
The cleanup action that spring performs when the instance is destroyed.
Location: Using the method level
Parameters: None
Turn from: http://blog.csdn.net/zhang854429783/article/details/6785574
For a long time did not
ANNOTATION,SPRING,AOP concepts such as this is not introduced here, the relevant knowledge on the Internet in a large pile, but also the major companies interview must test content. A large part of the current AOP technology scenario should be used to implement operational logging, since almost every company has its own development framework, and many frameworks are highly encapsulated in such operations as
Overview
Spring 3.1 introduces an exciting, annotated (annotation) cache technology that is inherently not a specific caching implementation (such as EHCache or oscache), but rather an abstraction of the cache usage, The effect of the return object of a cached method can be achieved by adding a small amount of the various annotation that it defines in the existi
============== Registration ==================Label to the class header, register this class with spring to manage the creation@Repository Data Persistence layer@Service Business Layer Bean@Controller Presentation Layer Bean@Component not recommended for use====== other Properties 1Lazy-init= "true"//whether deferred initializationScope= the life cycle of the "prototype"//beandepends-on= "Other beans"//depe
Spring MVC data verification-validate annotation method, mvcvalidate1. Description
Before learning the annotation method, you should first learn the encoding method spring injection. This helps you understand how the verification framework works. When an error occurs, the problem can be better solved. Therefore, this b
Using annotations to implement spring's declarative transaction management is simpler.
Steps:
1 must introduce AOP-related jar files
2 implementation of declarative transaction management and the application of the transaction manager class in the specified annotation method in Bean.xml
3 where you need to add a transaction control, write: @Transactional
@Transactional notes:
1 Annotation of application tr
First or the configuration file for XMLXML version= "1.0" encoding= "UTF-8"?>Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"Xmlns:context= "Http://www.springframework.org/schema/context"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd Http://www.springframework.org/schema/context http://www.springframework.org/sc
Annotation-based controller in spring mvc
The annotation-based controller can contain multiple request processing methods in a controller class. This article describes annotation classes that are frequently used in spring mvc, including:The
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.