我尝试更新整个应用程序并使用 PostgreSQL 的反应式编程方法,因此我正在更新存储库并使它们从 R2dbcRepository 扩展,还更新了相关服务以处理 Mono 和 Flux。当我尝试运行应用程序时出现异常
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'temperatureLibraryReactiveRepository'
defined in com.PlayGroundAdv.Solar.repositories.reactive.TemperatureLibraryReactiveRepository defined
in @EnableR2dbcRepositories declared on SolarApplication: Invocation of init method failed
nested exception is java.lang.IllegalArgumentException: Failed to create query for method
public abstract reactor.core.publisher.Flux
com.PlayGroundAdv.Solar.repositories.reactive.TemperatureLibraryReactiveRepository.findAll(org.springframework.data.domain.Pageable)!
No property findAll found for type TemperatureLibraryEntity!
我不确定这是否是由于使用了Pageable
,如果是这种情况,我没有找到Pageable
R2DBC 方法的任何替代方法。
过去使用 JPA 方法可以正常工作的一切都是我的存储库
import com.PlayGroundAdv.Solar.entity.TemperatureLibraryEntity;
import com.PlayGroundAdv.Solar.model.AllPostalCodeModel;
import org.springframework.data.domain.Pageable;
import org.springframework.data.r2dbc.repository.Modifying;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import javax.transaction.Transactional;
@Repository
public interface TemperatureLibraryReactiveRepository extends R2dbcRepository<TemperatureLibraryEntity, Long> {
// A.B 11-18 Get All Temp By postal Code
Flux<TemperatureLibraryEntity> findByPostalCode(String postalCode, Pageable pageable);
String FIND_POSTAL_CODE = "SELECT new com.PlayGroundAdv.Solar.model.AllPostalCodeModel ( u.id, u.postalCode) FROM TemperatureLibraryEntity u order by u.postalCode";
@Transactional
@Modifying
@Query(value = FIND_POSTAL_CODE)
Flux<AllPostalCodeModel> findAllPostalCode();
Flux<TemperatureLibraryEntity> findAll(Pageable pageable);
}