How to disable the default exposure of Spring Data REST repositories?

Looping back here as I was looking for this specific setting. It looks like this is now implemented. In this case, you would want to set spring.data.rest.detection-strategy=annotated to avoid default exposure. All application.properties options: # Exposes all public repository interfaces but considers @(Repository)RestResource\u2019s `exported flag. spring.data.rest.detection-strategy=default # Exposes all repositories independently of type visibility and … Read more

JedisConnectionFactory setHostName is deprecated

With Spring Data Redis 2.0, those methods have been deprecated. You now need to configure using RedisStandaloneConfiguration Reference: https://docs.spring.io/spring-data/redis/docs/current/api/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.html#setHostName-java.lang.String- Example: JedisConnectionFactory jedisConnectionFactory() { RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(“localhost”, 6379); redisStandaloneConfiguration.setPassword(RedisPassword.of(“yourRedisPasswordIfAny”)); return new JedisConnectionFactory(redisStandaloneConfiguration); }

Pagination with mongoTemplate

It’s true that the MongoTemplate doesn’t have findXXX with Pageables. But you can use the Spring Repository PageableExecutionUtils for that. In your example it would look like this: Pageable pageable = new PageRequests(page, size); Query query = new Query().with(pageable); List<XXX> list = mongoTemplate.find(query, XXX.class); return PageableExecutionUtils.getPage( list, pageable, () -> mongoTemplate.count(Query.of(query).limit(-1).skip(-1), XXX.class)); Like in the … Read more

Spring Data JPA intelligence not working in Intellij

I solved this problem by adding JavaEE Persistence framework support. Just right click on the project, select Add Framework Support and then scroll down to find the JavaEE Persistence, then enable the checkbox and hit OK: Adding JavaEE Persistence Facet It will add a persistence.xml file, you can delete it. Finally your auto completions will … Read more

Why does RestTemplate not bind response representation to PagedResources?

As you’ve discovered correctly, PagedResources does not have an _embedded property, that’s why you don’t get the content property populated. This dilemma can be solved in two different ways: Providing a type that matches the representation in the first place. Thus, craft a custom class and either stick to the property names of the representation … Read more

Spring JpaRepostory delete vs deleteInBatch

The answers here are not complete! First off, let’s check the documentation! void deleteInBatch(Iterable<T> entities) Deletes the given entities in a batch which means it will create a single Query. So the “delete[All]InBatch” methods will use a JPA Batch delete, like “DELETE FROM table [WHERE …]”. That may be WAY more efficient, but it has … Read more