Tag Archives: spring framework
Java – Configure MySQL for Google Appengine (Standard)
In this post, you will learn about how to configure MySQL properties in your Spring Boot application for deploying it on Google AppEngine (Standard) environment. This article assumes that the MySQL database is set up as part of Google Cloud SQL fully-managed database service. The following will be covered: Configuration properties in Application.properties Configure POM entries in pom.xml file Configuration properties in Application.properties In application.properties file, while working with Spring Boot app with JPA repository, you need to have following configuration properties in application.properties file. The below assumes that you have a MySQL database with name as dbname and username/password as root/root. In above properties, the instance connection name can be …
Google Recaptcha with Angular and Spring App – Example
In this post, you will learn about how to implement Google Recaptcha with Angular and Spring/Java App. Get Recaptcha code (Key) from Google Angular – Process the Recaptcha code in Login/Sign up Component Spring/Java – RecaptchaVerifier utility class Spring/Java – Verify the Recaptcha Response in Server Side Code Get Recaptcha Code (Secret Keys) from Google Go to Google Recaptcha website and get the code for your website. The Google recaptcha code looks like following: Place the code in appropriate place in login, signup pages. In the login form, it would with code such as following: The Signup form with Google Recaptcha would look like following. The working example can be …
Integrate MailGun with Spring Boot and Java App
In this post, you will learn about integrating your Spring Boot & Java app with MailGun REST API. The following are some of the points covered: Create & Configure/Load MailGun API details MailGun EmailService custom implementation Spring RestTemplate implementation Invoke/Test Email Service Create & Configure/Load MailGun API Details The following represents the Config class used to load the configuration beans by loading the properties from application.properties file. The following represents the code in application.properties file: You could get the above details from MailGun Dashboard. MailGun EmailService Custom Implementation Pay attention to some of the following in the code sample given below: Custom RestClient (Spring RestTemplate) is used for making calls …
Integrate Send Grid with Spring Boot & Java App
In this post, you will learn about integrating your Spring Boot & Java app with SendGrid Web API. The following are some of the points covered: Create & Configure/Load SendGrid API Key Configure SendGrid Maven entry in POM.xml SendGrid EmailService custom implementation Invoke/Test Email Service Create & Configure/Load SendGrid API Key Create an account with SendGrid.com Go to SendGrid Setup Guide using Web API page. Create an API key. Execute the following script in your development environment. Alternatively, you could also configure the SendGrid API key in your application.properties file and read the key details as part of loading configuration beans. The following is the sample code: In the above code …
AWS SNS Example with Spring Boot & Java
Amazon Simple Notification Service (SNS) is a fully managed pub/sub messaging and mobile notifications service for coordinating the delivery of messages to subscribing endpoints and clients. One can get started with Amazon SNS using AWS console or AWS CLI or AWS SDK. One example of how Amazon SNS can be used is the following: Publish a JSON message (consisting of phone no. and message) to Amazon SNS topic Above which will result in triggering an Amazon Lambda function which could in turn trigger Amazon Polly to generate text-to-speech, and, subsequently, invoke Twilio API to make the call to destined phone number. In this post, you will learn about how to …
Spring Boot & Angular 5 PWA Dev Environment Setup
In this post, you will learn about how to quickly create development environment to build an app using Spring Boot and Angular 5. Angular 5 app and Spring Boot is deployed as one single unit on Tomcat server. The following points are covered: Create a Spring Boot Spring Starter Project Create an Angular Service Worker Project Modify POM.xml for Copying Angular App Assets Create a deployment script for automated build and deployments Create a Spring Boot Spring Starter Project Within Eclipse IDE, create a Spring Starter Project for sample Spring Boot app. You may download to SpringSuite Tool Suite (STS) from Eclipse marketplace to have options such as Spring starter …
Spring Boot JPA MySQL Sample App – Code Example
Creating a Spring Boot app with MySQL data source is something every Java developer come across when thinking of creating a quick POC or app. This post is aimed to provide quick code samples which can be used to quickly create a MySQL-based Spring boot app. In this post, you will learn about code examples in relation to getting setup with Spring Boot app which interacts with MySQL database. The following are some of the topics covered: Define properties in application.properties file Create/Configure Database-related Beans Create Entity Classes (Domain) Create Database Implementation Classes (DAOs) Define Service Classes for interacting with Data Access Objects Invoke service class from SpringBoot main program …
Twilio & AWS S3 using Java & Spring Boot – Code Example
Twilio is a very popular communication service which could be used to send SMS, make the phone or video calls to people in different countries. In this post, you will learn about creating Java and Spring Boot app in relation to how to use Twilio phone service to make a phone call and play audio stored at AWS S3 bucket. The following are some of the related use cases: Play security and other alerts via phone calls Play messages of any kind via phone calls The following are some of the topics which would be covered in this post: Define VoiceService interface defining APIs Create Twilio Voice Service implementation Load …
AWS Temporary Credentials with Java & Spring Boot
AWS Security Token Service (STS) is an Amazon web service which enables you to request temporary, limited-privilege credentials for AWS Identity and Access Management (IAM) users or for users that you authenticate (federated users). By default, the AWS Security Token Service (AWS STS) is available as a global service, and all AWS STS requests go to a single endpoint at https://sts.amazonaws.com. You can optionally send your AWS STS requests to endpoints in any of the AWS regions shown in the table that follows. In this post, you would learn how to use AWS security token service to create temporary security credentials with Spring Boot and Java app. I would recommend …
10 Spring Framework Interview Questions for Freshers
Spring Framework is one of the most popular and widely used Java frameworks which makes it very easy to create a Java application/web application using several out-of-box framework components provided by Spring. Thus, it is imperative that beginners starting to do Java web app would end up using Spring framework for building the app. From that perspective, it becomes of great importance for beginners to take note of some of the basic concepts related to which interview questions can be asked. In this post, you will learn some of the Spring framework fundamentals concepts which could be asked in form of interview questions and answers. These questions and answers may …
Amazon S3 with Spring Boot & Java – Sample Code
Amazon Simple Storage Service (S3) is an AWS object storage platform which helps you to store the files/data in form of objects, and, store and retrieve any amount of data from anywhere – websites and mobile apps, corporate applications, and data from IoT sensors or devices. Each file stored in Amazon S3 (as an object) is represented using a key. The following are some of the usecases where S3 could be used. Thus, it becomes of utmost importance to understand how to interact with Amazon S3 API using AWS SDKs including AWS Java SDK. Backup & recovery Data archiving Big data analytics Disaster recovery Cloud-native application data Hybrid cloud storage …
Amazon Polly Hello World with Java & Spring Boot
Amazon Polly is one cool AWS service which can be used to achieve requirements such as creating business, security alerts via phone call. When integrated with communication providers such as Twilio, several value-added services could be created using Amazon Polly AWS service. In this post, you will learn about creating a sample Java app which uses Amazon Polly service for converting text to speech. You should be able to listen to the following text using the program given below: Hello World! How are you doing? This is Polly. I am happy to talk with you. The following are some of the aspects covered in this post: Create a Spring Boot app …
Spring Boot CommandLineRunner Code Example
Spring Boot helps you quickly get started with building a Spring-based web app in no time. All you need to do is go to Eclipse IDE, create a new Spring Starter Project and that is it. This is provided you installed Eclipse plugin, Spring Tools (aka Spring IDE and Spring Tool Suite) by going to Help > Eclipse Marketplace… and searching for “spring tools” keyword. Often, one wants to run a Spring Boot app as a Java application as like a traditional Java program and test different parts of their app. In this post, you will get a template code for quickly getting started with Command Liner which would help …
Spring Boot & Angular App Hello World as One Deployable War
This article represents steps and related code samples to deploy an Angular app (created with Angular 2.*, Angular 4.* or Angular 5.*) with a Spring Boot / Spring Web app as one deployable unit (war file) on the web server such as Tomcat, Jetty etc. Different Deployment Strategies for Spring Boot and Angular App The following are the two different strategies which can be used for deploying web app built with Angular 5.* (and previous versions such as Angular 4.* or Angular 2.*) used for doing client side programming and Spring boot with Spring Web for server-side programming. Deploy Angular App and Spring Boot / Spring Web app as different applications running on different servers; This implies that users connect …
Spring Framework Interview Questions & Answers – Set 1
This is a practice test / interview questions and answers for Java Developers working on Spring Framework. These questions can be used to check your knowledge on Spring framework fundamentals. They could be useful and helpful in preparing you for upcoming interview in relation with Spring framework. The following are some of the topics in relation with Spring Framework Fundamentals which are covered in this practice test: Spring IOC concepts Configuration metadata Beans packages for IOC container Beans instantiation Different types of DI techniques (Constructor-based, Setter-based DI) Beans initialization (Eager / lazy initialization) Method injection techniques (lookup method, arbitrary method injection) Bean Scopes (Singleton, Prototype, Request, Session, Application, WebSocket) Practice Test on Spring Framework Fundamentals [wp_quiz id=”6035″]
How to Configure SpringLoaded with Eclipse Dynamic Web Project
The article presents simple steps to use SpringLoaded framework to have your classes loaded onto the tomcat server without you having required to restart the server, while you are working with Eclipse Dynamic Web Project. The instructions below applies when you have installed Tomcat server and added the same to the eclipse. Quick Introduction on SpringLoaded SpringLoaded, a framework published by Spring.io, is a JVM agent for reloading class file changes whilst a JVM is running. It transforms classes at loadtime to make them amenable to later reloading. Read further on this github page. Personally, I have found it very useful as I do not have to build and restart servers …
I found it very helpful. However the differences are not too understandable for me