小编sre*_*har的帖子

java.lang.IllegalArgumentException:在除Pageable和Sort之外的所有参数上都使用@Param键入一次,或者根本不使用

我正在使用Spring Data Cassandra,将多个参数传递给存储库方法时出现异常。任何人都可以帮助如何传递多个参数以追加和使用where子句。

我的回购方法:

@Query("select site_name,month_gen from mykeyspace.dgr_item where type='Site' and name = ?0 and dgr_date in (:list)")
public List<Object> findGen(String siteName, @Param("list") List<Date> listt);
Run Code Online (Sandbox Code Playgroud)

例外:

Caused by: java.lang.IllegalArgumentException: Either use @Param on all parameters except Pageable and Sort typed once, or none at all!
at org.springframework.util.Assert.isTrue(Assert.java:68)
at org.springframework.data.repository.query.Parameters.assertEitherAllParamAnnotatedOrNone(Parameters.java:294)
at org.springframework.data.repository.query.Parameters.<init>(Parameters.java:91)
at org.springframework.data.cassandra.repository.query.CassandraParameters.<init>(CassandraParameters.java:45)
at org.springframework.data.cassandra.repository.query.CassandraQueryMethod.createParameters(CassandraQueryMethod.java:131)
at org.springframework.data.cassandra.repository.query.CassandraQueryMethod.createParameters(CassandraQueryMethod.java:45)
at org.springframework.data.repository.query.QueryMethod.<init>(QueryMethod.java:75)
at org.springframework.data.cassandra.repository.query.CassandraQueryMethod.<init>(CassandraQueryMethod.java:64)
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactory$CassandraQueryLookupStrategy.resolveQuery(CassandraRepositoryFactory.java:152)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:436)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263)
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactoryBean.afterPropertiesSet(CassandraRepositoryFactoryBean.java:76)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 41 common …
Run Code Online (Sandbox Code Playgroud)

spring cassandra spring-boot spring-data-cassandra

5
推荐指数
2
解决办法
4413
查看次数

如何配置spring的RestTemplate发出http2请求?

我有一个RestClient调用GET请求到spring服务(服务器),该服务器正在接受HTTP2请求,并且我得到302作为响应。如何使用spring RestTemplate发送Http2请求。

Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://example.com/static/mobile/get-token": unexpected end of stream on Connection{domain.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}; nested exception is java.io.IOException: unexpected end of stream on Connection{example.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:600)
at com.domain.Sample.main(Sample.java:45)
Caused by: java.io.IOException: unexpected end of stream on Connection{example.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}
    at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:205)
    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at …
Run Code Online (Sandbox Code Playgroud)

spring resttemplate spring-boot microservices spring-rest

4
推荐指数
1
解决办法
1617
查看次数