Annotations in Spring

Source: Internet
Author: User

@Repository represents the warehouse. General annotations on the DAO implementation class, when others look at the code, they know that the class is a class that is related to the data store.

@Service represent the business. General annotations are on the service implementation class. The @Controller represents the controller. General annotations are on the controller class. If your class is not of the above type (data storage class, business class, Controller), you can use @component in general

Spring things are controlled by declarative things and programmed things

The declared thing is configured with XML configuration and annotation two configuration methods.

Annotation configuration

<BeanID= "TransactionManager"class= "Org.springframework.orm.hibernate3.HibernateTransactionManager">

< Propertyname= "Sessionfactory"ref= "Sessionfactory" />
</Bean>
<Context:annotation-config/>

     < tx:annotation-driven  transaction-manager = "TransactionManager"   />  

XML Configuration

< Bean class = "Org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator" >

< Propertyname= "Beannames">
<List>
<value>*service</value>
<value>*dao</value>
</List>
</ Property>
< Propertyname= "Interceptornames">
<List>
<value>Transactioninterceptor</value>
</List>
</ Property>
</Bean>

<BeanID= "Transactioninterceptor"
Class= "Org.springframework.transaction.interceptor.TransactionInterceptor"Autowire= "Default">
< Propertyname= "TransactionManager"ref= "TransactionManager" />
< Propertyname= "Transactionattributes">
<Props>
<propKey="*">Propagation_required</prop>
</Props>
</ Property>
</Bean>
<BeanID= "TransactionManager"
Class= "Org.springframework.orm.hibernate4.HibernateTransactionManager">
< Propertyname= "Sessionfactory"ref= "Sessionfactory" />
</Bean>

     

Annotations in Spring

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.