对于注释类型Transactional,未定义属性readOnly

Vip*_*ain 4 java spring transactions

当我将这段代码放在服务方法上时,我收到此错误

 @Transactional(readOnly =true)
Run Code Online (Sandbox Code Playgroud)

我正在编写此代码以使事务只读.你能告诉我在这种情况下我做错了什么

Bnr*_*rdo 10

确保导入@Transactionalorg.springframework.transaction.annotation.Transactional,而不是从javax.transaction.Transactional作为readOnly属性是特定于Spring的事务.