spring in transaction configuration

1: Transaction implementation is achieved through a dynamic proxy; through xml configuration:

 

1: wherein, <tx: method name = "trans" /> name attribute, support wildcard, such as * name = "trans *" to represent all methods starting trans, apply

 

A common transaction configuration:

2: Use annotations arranged affairs:

 

Add notes DI parser, IOC annotation parser, the parser notes Affairs (TX comment parser <tx: annotation-diven transaction-manager = "txManager">), this transaction parser has a very important parameter, is to configure transaction manager txtManager; transaction essentially dynamic proxy, by default JDK dynamic proxy, if you do not use dynamic proxy JDK, choosing instead to use dynamic proxy cglib embodiment, the property may be provided as shown in (false JDK is, as cglib to true); (JDK dynamic proxy and the main difference is that JDK dynamic proxy cglib is based on the interface, cglib not based interfaces)

 

Note: The role of annotation parser is certain notes can be resolved

Configuration data source (the DataSource) is necessary; db.properties configuration is also necessary; the rest configuration, are available through @Transactional annotation as

 

 

 

 

Guess you like

Origin www.cnblogs.com/panbin/p/11324433.html