Tag: springboot

  • How to map JSON data in PostGreSQL database to a Hibernate Entity column?

    PostGreSQL database is one of the most popular open source databases . It has features which traditional relational databases lack , like storing a JSON as itself in the database. JSON is a widely used communication data format and hence this feature comes quite handy. The problem arises when you use an ORM tool like…

  • How to auto generate and auto increment identifier values for PostGreSQL tables through Hibernate?

    I was trying to connect to PostGreSQL database through Spring Boot. I used spring-boot-starter-data-jpa dependency which automatically included hibernate dependencies to the project. And since I was connecting to postgresql database I included the following postgresql dependency as well: I created a simple table named my_table with an integer ID and a JSON data type…

  • How to populate application properties dynamically in Spring Boot?

    Assumption: Maven is used to build the spring boot project Let’s say you want to populate application.properties dynamically while building the project in Spring Boot. You can fetch those properties from various sources like: pom.xml an external file System properties settings xml of Maven To accomplish this , define the properties in application.properties like this…

  • How to dockerize Spring Boot app the version 2.3.0 way?

    Spring Boot released its latest version 2.3.0 two days back (15 May 2020). One major feature provided by this release is creating docker images of a spring boot app in a much more efficient way. Prior to this , if you were to dockerize your spring boot app you need to take the jar generated…

  • How to secure a REST service in Spring Boot using Basic Authentication?

    Rest Services can be secured in a variety of ways: Basic Authentication , Bearer Authentication , API Keys , Open Id etc. Basic Authentication is the simplest , it uses a user name and password to secure a REST service. In this post let’s see how to protect a REST service using basic authentication in…

  • How to send multiple headers using Open Feign ?

    If you are consuming a REST service in Spring using Open Feign , you may come across scenarios where multiple headers need to be set. In the previous post: How to invoke a basic authenticated REST service using Open Feign? I explained how to set Authorization header while consuming a basic authenticated REST service. You…

  • How to invoke a REST service protected by BasicAuth using Spring Open Feign?

    Invoking REST services from Spring is much easier if you use Spring Open Feign. It allows you to invoke REST services declaratively and saves a lot of code. Here is the post explaining the basic concept of Open Feign: How to call a REST service declaratively using Open Feign? It is a very simple example…

  • How to call a REST service from Spring declaratively using OpenFeign?

    If you are using Spring, you are probably using Rest Template provided by Spring to invoke third party REST services. That involves some code , preparing the REST template , populating the parameters required for one of the methods exposed by the REST template and finally invoking one of its specific methods. What if you…

  • How to consume a REST service which accepts form data in Spring?

    Let’s say you want to consume a REST service from your Spring Boot / Spring MVC application. The developer who created the REST service you wanted to consume, developed it in such a way that it accepts only form data. May be he created it to accept data from HTML forms. And now you want…