Why is data getting stored with weird keys in Redis when using Jedis with Spring Data?

Ok, googled around for a while and found help at http://java.dzone.com/articles/spring-data-redis. It happened because of Java serialization. The key serializer for redisTemplate needs to be configured to StringRedisSerializer i.e. like this: <bean id=”jedisConnectionFactory” class=”org.springframework.data.redis.connection.jedis.JedisConnectionFactory” p:host-name=”${redis.server}” p:port=”${redis.port}” p:use-pool=”true”/> <bean id=”stringRedisSerializer” class=”org.springframework.data.redis.serializer.StringRedisSerializer”/> <bean id=”redisTemplate” class=”org.springframework.data.redis.core.RedisTemplate” p:connection-factory-ref=”jedisConnectionFactory” p:keySerializer-ref=”stringRedisSerializer” p:hashKeySerializer-ref=”stringRedisSerializer” /> Now the key in redis is vc:501381. Or … Read more

Spring Boot and how to configure connection details to MongoDB?

Just to quote Boot Docs: You can set spring.data.mongodb.uri property to change the url, or alternatively specify a host/port. For example, you might declare the following in your application.properties: spring.data.mongodb.host=mongoserver spring.data.mongodb.port=27017 All available options for spring.data.mongodb prefix are fields of MongoProperties: private String host; private int port = DBPort.PORT; private String uri = “mongodb://localhost/test”; private … Read more

How to Log HttpRequest and HttpResponse in a file?

For logging the request Spring has the AbstractRequestLoggingFilter class (well actually one of the subclasses). This can be used to log the incoming request (before and after processing). Depending on the configuration this can include the payload, client information and full URL (including erquest parameters). All these three are disabled by default but can be … Read more

How to configure Spring Data JPA using XML

If you want to configure Spring Data JPA by using XML configuration (and use the configuration described in the book), you have to follow these steps: Configure the data source bean. Configure the entity manager factory bean. Configure the transaction manager bean. Enable annotation driven transaction management. Configure Spring Spring Data JPA. The application context … Read more

Can I make a custom controller mirror the formatting of Spring-Data-Rest / Spring-Hateoas generated classes?

I’ve found a way to imitate the behavior of Spring Data Rest completely. The trick lies in using a combination of the PagedResourcesAssembler and an argument-injected instance of PersistentEntityResourceAssembler. Simply define your controller as follows… @RepositoryRestController @RequestMapping(“…”) public class ThingController { @Autowired private PagedResourcesAssembler pagedResourcesAssembler; @SuppressWarnings(“unchecked”) // optional – ignores warning on return statement below… … 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 data : CrudRepository’s save method and update

I wanted to know if the {save} method in CrudRepository do an update if it finds already the entry in the database The Spring documentation about it is not precise : Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance completely. But as … Read more

How to correctly use PagedResourcesAssembler from Spring Data?

You seem to have already found out about the proper way to use but I’d like to go into some of the details here a bit for others to find as well. I went into similar detail about PagedResourceAssembler in this answer. Representation models Spring HATEOAS ships with a variety of base classes for representation … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)