草庐IT

jazn-data

全部标签

redis - Spring data redis 在反序列化 List 类型时返回 null

我正在使用springdataredis,我的一个实体有如下列表。@RedisHash("person")@Data@BuilderpublicclassPersonimplementsSerializable{@IdprivateStringname;privateListaddressList;}publicclassAddressimplementsSerializable{privateStringpostCode;privateStringcountry;}序列化工作正常,地址存储为HGETALLperson:123456"name""blabla""address[0].p

java - 错误 : Ambiguous handler methods mapped for HTTP path in spring data rest

这是代码:@Import(Appconfig.class)@RestController//@RequestMapping("/api/destination/find")publicclassRestApi01_Controller{@AutowiredpublicCountryRepoCountry_Repository;@AutowiredpublicCityRepoCity_Repository;@AutowiredpublicAirportRepoAirport_Repository;@AutowiredpublicResortRepoResort_Repository;@R

spring - MongoRepository 对比两列+Spring Data

我想使用mongorepository+spring数据(HQL或标准查询)执行比较两列值的查询。我正在向您展示关系查询,我想转换为mongo。Select*fromEmployeeemwhereem.limit我想使用Spring数据将上述查询转换为HQL查询。 最佳答案 您可以使用$where来实现:db.employee.find({$where:"this.limit在此处查看文档:https://docs.mongodb.com/manual/reference/operator/query/where/

java - Spring Data Rest PATCH 禁止更新特定字段

我目前正在使用spring-data-rest开发一个小型RESTweb服务:org.springframework.bootspring-boot-starter-data-rest我遵循了以下指南:https://spring.io/guides/gs/accessing-mongodb-data-rest/它工作得很好。我在我的Person.class上添加了一些注释,以便在POST请求(如@NonNull等)期间验证对象,如下所示:publicclassPerson{@IdprivateStringid;@NonNullprivateStringfirstName;@NonNu

java - spring data mongodb版本与spring的兼容性

这是我的pom.xmlorg.springframeworkspring-core5.0.0.RELEASEorg.springframeworkspring-context5.0.0.RELEASEorg.springframeworkspring-web5.0.0.RELEASEorg.mongodbmongo-java-driver3.5.0org.springframework.dataspring-data-mongodb2.0.0.RELEASE这是我的Bean配置当我尝试运行我的项目时,出现以下异常SEVERE:Exceptionsendingcontextinitial

mongodb - Spring Data 的 TTL 索引定义

我想用SpringDataAnnotations创建TTL索引。在我的例子中,我不能使用@Indexed(name="ttl_index",expireAfterSeconds:1000)放在类的字段上,但我想在类级别定义索引复合索引。有可能的?但愿如此。或者,我可以在Java中使用索引而不使用注释吗? 最佳答案 不,这是不可能的。仅使用@IndexedSpringDataMongoDBapi。作为documentation说,限制之一是:TTL索引是单字段索引。复合索引不支持TTL,忽略expireAfterSeconds选项。

java - 从静态 ThreadLocal 变量更改 Spring Data Repositories 的 Mongo 集合是否线程安全?

我想使用SpringDataMongo存储库并在运行时指定文档集合。我在这张票中找到了实现它的方法DATAMONGO-525以及我所做的:使用ThreadLocal变量和链接集合名称创建了GenericObject这个静态变量:@Data@Document(collection="#{T(com.test.myproject.model.GenericObject).getCollection()}")publicclassGenericObject{privatestaticThreadLocalcollection=newThreadLocal();@IdprivateObject

java - Spring Data MongoDB nosql注入(inject)

我有一个问题。spring数据中的mongo存储库中的查询是否可以免受NoSQL注入(inject)攻击?是否有可能成功地对spring-boot应用程序执行此类攻击?例如,如果我创建使用我自己的方法扩展MongoRepository的接口(interface),是否以安全的方式生成默认查询,这样的攻击是不可能的?谢谢 最佳答案 我使用一个mongo存储库创建了小型SpringBoot应用程序。我对它执行了一些基本的NoSQL注入(inject)攻击,为了确保它们有效,我还使用Robo3T进行了攻击,并检查了输出是否符合我的预期。例

mongodb - spring data mongo db ldap认证

我们公司最近从基本身份验证更改为LDAP身份验证,常规应用程序现在在URL上使用authSource=$external&authMechanism=PLAIN。这在普通应用程序上运行良好,但我不知道如何使用SpringData设置它们。肯定有办法做到这一点,对吧? 最佳答案 正如您在下面看到的,您无法设置诸如authSource/authMechanism之类的内容,因此您必须更改为使用URI。另请注意,在使用URI时,您不能使用主机/端口和用户名/密码。这些都需要进入URI。有点像exportspring_data_mongod

mongodb - Spring Data Mongo 的日期类型的@Id

spring-data-mongodb的datapojo配置如下:@Document(collection="DateKey")publicclassDateKey{@IdprivateDatedateid;privateDatedateval;privateStringfirstName;privateStringlastName;@Id列是一个java.util.Date字段,当使用spring-data-mongodb将数据保存在mongo-db中时,它被保存为{"_id":ObjectId("5a356628d73a971c3c8ab1e7")}无论何时使用其他数据类型,都不会