Mysql 使用只读事务Spring引导调用存储过程

Mysql 使用只读事务Spring引导调用存储过程,mysql,spring-boot,jpa,spring-data-jpa,spring-data,Mysql,Spring Boot,Jpa,Spring Data Jpa,Spring Data,我的程序如下: @NamedStoredProcedureQueries({ @NamedStoredProcedureQuery(name = "getFilteredServiceCentersStoredProcedure", procedureName = "getFilteredServiceCentersStoredProcedure",parameters = { @StoredProcedureParameter(name = "searchTex

我的程序如下:

@NamedStoredProcedureQueries({
    @NamedStoredProcedureQuery(name = "getFilteredServiceCentersStoredProcedure", procedureName = "getFilteredServiceCentersStoredProcedure",parameters = {
            @StoredProcedureParameter(name = "searchText", mode = ParameterMode.IN, type = String.class),
            @StoredProcedureParameter(name = "sectorId", mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(name = "lat", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "lon", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "currentLatitude", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "currentLongitude", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "radius", mode = ParameterMode.IN, type = Double.class),
            @StoredProcedureParameter(name = "serviceCenterTypes", mode = ParameterMode.IN, type = String.class),
            @StoredProcedureParameter(name = "pageOffset", mode = ParameterMode.IN, type = Long.class),
            @StoredProcedureParameter(name = "pageSize", mode = ParameterMode.IN, type = Integer.class),
            @StoredProcedureParameter(name = "totalCount", mode = ParameterMode.OUT, type = Long.class) }) })
我正在尝试在服务内部调用此选项,方法是:

@Transactional(readOnly = true)
春天一直给我:

Connection is read-only. Queries leading to data modification are not allowed

现在,我的存储过程是只读的,我希望它可以从我的已读副本中读取,因此我必须将连接标记为只读。

当存储过程不更改任何数据时,您不必关心事务是否为只读。我不能这样做,由于MySQL复制驱动程序使用只读注释路由到适当的副本,因此我需要transactional=readOnly