Using RestTemplate in Spring boot
Using RestTemplate in Spring boot problem You wish to quickly send an Http Request, for example to an API and get back its response. In this post we’re gonna use the https://www.themealdb.com/ API for testing purposes and because I like it. SOLUTION Using the RestTemplate object. In Spring boot, we can autowire the RestTemplate and […]
Using the @Value annotation in Spring Boot
Using the @Value annotation in Spring Boot problem You want to use a value from a properties file to load into a field in your class. In this post we will see how to do that using Spring boot. SOLUTION Using the @Value annotation. We can place this annotation on a field, e.g. String. Let’s […]
How to change Spring’s Boot startup ASCII message
How to change Spring’s Boot default startup ASCII message problem You wish to change the default banner – logo of Spring Boot. The default one at the time of writing this post looks like this: SOLUTION 1 – ASCII Create a text based banner (ASCII) and place it in the classpath with a file title: […]
How to change server’s port number in Spring Boot
How to change the server’s port number in spring boot problem You have a Java web application that uses Spring Boot and you wish to change the default port number (i.e. 8088) the web server is running on. SOLUTION 1 One solution is by specifying the preferred port number in the application.properties file as follows: […]
Send an email using Java and Spring boot and Gmail
Send an email using Java and Spring boot and gmail problem You wish to use email functionality in your web application that is built using the Spring framework. In this post we will see how to accomplish it using a Gmail account. Also, I will be using IntelliJ IDEA Ultimate edition (that supports Spring Framework) […]
Creating an Echo controller in Java with Spring boot
Creating an echo controller in Java with Spring boot problem You wish to create an endpoint in your web application that when it is hit, it echoes back the data you’re sending. A basic example would be to add a parameter message and then it prints it back. SOLUTION Let’s create a Spring Boot project. […]
Show table of data using Spring boot and ThymeLeaf
Show table of data using Spring boot and ThymeLeaf Problem Building a web application in Java that will be showing a table of data in the frontend, be that web browser on a Desktop, laptop or mobile phone. Solution Spring framework comes to the rescue. It will help us to build the server that will […]
Parsing polymorphic models in Spring boot
Parsing polymorphic models in Spring boot problem You wish to build a web application that will be accepting HTTP POST requests with JSON objects in their request body to be parsed into your Java models. On top of that, the models will be using enums and inheritance. SOLUTION Spring boot to the rescue. Using IntelliJ […]