Common annotations for Spring beans@Component: usually annotations, available for any bean@Repository: Typically used to annotate the DAO layer, which is the persistence layer@Service: Typically used to annotate service tiers, or services tiers@Controller: Typically used to annotate the controller layer, which is the control layerAutomatic detection of classes an
return (after return advice): A notification that is executed after a connection point has completed normally, and does not include cases where an exception was thrown. The ApplicationContext uses
Wrapping Notification (Around advice): A notification that surrounds a connection point, similar to the Dofilter method of the filter in the servlet specification in the Web. You can customize the behavior before and after the call to the method, or you can choose not to execute. The Applicat
return (after return advice): A notification that is executed after a connection point has completed normally, and does not include cases where an exception was thrown. The ApplicationContext uses
Wrapping Notification (Around advice): A notification that surrounds a connection point, similar to the Dofilter method of the filter in the servlet specification in the Web. You can customize the behavior before and after the call to the method, or you can choose not to execute. The Applicat
configuration file Config/applicationcontext.xml, which can be used: Getservletcontext (). Getinitparameter ("ParaName"); Read the value.Note: The difference between Init-param and Context-param can be seen from the name, which is relative to the entire Web application, whereas the former is for a single servlet.2. Springmvc.xmlLet's take a look at how Springmvc.xml should be configured:Enable the annotation driver to scan the controller, specify the
Simple Spring annotation Injection Using Reflection
On the Rise of the moment, I looked at the source code of Spring over the past two days and wanted to write a simple Spring Injection Using annotation !! Spring
;
Import Org.springframework.context.ApplicationContext;
Import Org.springframework.context.support.ClassPathXmlApplicationContext;
The public class Testannoweb {
@Test public
void Demo02 () {
//obtains
String Xmlpath = "from the Spring container =" Com/itheima/g_ Annotation/b_web/beans.xml ";
ApplicationContext ApplicationContext = new Classpathxmlapplicationcontext (xmlpath);
Studentaction st
(after return advice): A notification that is executed after a connection point is completed normally, excluding the case of throwing an exception. The ApplicationContext uses
Surround Notification (Around advice): A notification that surrounds a connection point, similar to the Dofilter method of the filter in the servlet specification in the Web. You can customize the behavior before and after the call to the method, or you can choose not to execute. The ApplicationContext uses
notifi
return (after return advice): A notification that is executed after a connection point has completed normally, and does not include cases where an exception was thrown. The ApplicationContext uses
Wrapping Notification (Around advice): A notification that surrounds a connection point, similar to the Dofilter method of the filter in the servlet specification in the Web. You can customize the behavior before and after the call to the method, or you can choose not to execute. The Applicat
object.The use of spring AOP can be based on two ways, one is more convenient and powerful annotation, the other is a good way to configure the XML.To start with annotations, use annotations to configure Spring AOP as a whole in two steps:The first step is to declare the activation of the auto-scan component feature in the XML file, while activating the automati
Add Ehcache Dependency package in 1.pom.xml2. Add ehcache configuration file under Classpath ehcache.xml3.spring configuration file Applicationcontext.xml need to be aware of adding red italic Partial configurationXmlns:cache= "Http://www.springframework.org/schema/cache" xsi: schemalocation= "Http://www.springframework.org/schema/cache http ://www.springframework.org/schema/cache/spring-cache-3.2.xsd" >4
@Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)@Documentedpublic @interface Component {/** * The value may indicate a suggestion for a logical component name, * to be turned into a Spring bean in case of an autodetected component. * @return the suggested component name, if any */String value() default "";}
@Target({ElementType.TYPE})@Retention(RetentionPolicy.RUNTIME)@Documented@Componentpublic @interface Repository {/** * The value may i
In addition to the XML-based configuration, Spring supports Annotation-based configuration. Spring provides the following Annotation to annotate a spring Bean:@Component: Annotate a normal Spring Bean@Controller: Labeling a Contro
The previous blog in the Spring Boot integration MyBatis, using the annotated configuration, I believe many people still prefer this elegant way, today we look at spring boot using mybatis annotation configuration detailed;
An example of modifying the previous project;
method of transmitting parameters
The insert operation implemented in the previous article is i
.
The following example briefly describes the spring annotation principle:
This example implements processing parsing for annotations on the set method and on the field properties. 1. Create an annotation
Package com.wuxing.learn.annotation;
Import Java.lang.annotation.ElementType;
Import java.lang.annotation.Retention;
Import Java.lang.annotation.RetentionPol
return (after return advice): A notification that is executed after a connection point has completed normally, and does not include cases where an exception was thrown. The ApplicationContext uses
Wrapping Notification (Around advice): A notification that surrounds a connection point, similar to the Dofilter method of the filter in the servlet specification in the Web. You can customize the behavior before and after the call to the method, or you can choose not to execute. The Applicat
The Apache CXF provides a convenient spring consolidation approach that exposes Web services and consumer Web services through annotations, Spring-labeled configurations
Various types of annotation. @WebService and @WebMethod are WSDL mapping annatotion. These Annotation relate the WSDL document element that describes
business layer components@Repository for labeling 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.
Premise: Spring has been deployed (refer to the previous article: Web project Deployment Spring Bean Factory)One: New dependent jar Package1:spring-aop-4.1.6.release.jar (required when modifying beans attribute in Applicationcontext.xml)Two: Web. xml unchanged, modify Applicationcontext.xml1: Remove DTD (2: New beans Attribute (xmlns,xmlns:xsi,xmlns:context,xsi:s
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.