关于javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional

@Transactional有两个不同的包。在Spring的事务管理中应该使用org.springframework.transaction.annotation.Transactional

Java EE 7 应用中,应该使用javax.transaction.Transactional。

英文:

Spring has defined its own Transactional annotation to make Spring bean methods transactional, years ago.

Java EE 7 has finally done the same thing and now allows CDI bean methods to be transactional, in addition to EJB methods. So since Java EE 7, it also defines its own Transactional annotation (it obviously can't reuse the Spring one).

In a Java EE 7 application, you'll use the Java EE annotation.

In a Spring application, you'll use the Spring annotation.

Their use is the same: informing the container (Java EE or Spring) that a method is transactional.


你可能感兴趣的:(spring,transactional,ejb)