1.發生錯誤500,異常報告如下圖:
主要錯誤提示:
Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
解決方式:
- 查看註解的事務@Transactional導包是否正確,以及是否在業務層的實現類中開啓事務
- 我的錯誤是導包錯誤,正確的是import org.springframework.transaction.annotation.Transactional;
- 注意要在類上方開啓事務。