Skip to content

Instantly share code, notes, and snippets.

View mmafrar's full-sized avatar

Afrar Malakooth mmafrar

  • NextLabs
  • Kuala Lumpur, Malaysia
  • LinkedIn in/mmafrar
View GitHub Profile
@mmafrar
mmafrar / ContactService.java
Created April 2, 2021 15:36
Implementing Spring Boot MVC CRUD operations with JPA and JSP
package com.example.demo.service;
import com.example.demo.model.Contact;
import com.example.demo.repository.ContactRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@mmafrar
mmafrar / ContactController.java
Created April 2, 2021 15:36
Implementing Spring Boot MVC CRUD operations with JPA and JSP
package com.example.demo.controller;
import com.example.demo.model.Contact;
import com.example.demo.service.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
@mmafrar
mmafrar / readcontact.jsp
Created April 2, 2021 15:38
Implementing Spring Boot MVC CRUD operations with JPA and JSP
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Read Contacts</h1>
<table border="2" width="70%" cellpadding="2">
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>Country</th>
@mmafrar
mmafrar / createcontact.jsp
Created April 2, 2021 15:39
Implementing Spring Boot MVC CRUD operations with JPA and JSP
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Create Contact</h1>
<form:form method="post" action="/create-contact">
<table>
<tr>
<td>Name: </td>
<td><form:input path="name"/></td>
</tr>
@mmafrar
mmafrar / updatecontact.jsp
Created April 2, 2021 15:40
Implementing Spring Boot MVC CRUD operations with JPA and JSP
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Update Contact</h1>
<form:form method="post" action="/update-contact/${id}">
<table>
<tr>
<td>Name: </td>
<td><form:input path="name"/></td>
</tr>
@mmafrar
mmafrar / EmailService.java
Created April 29, 2021 19:04
Sending emails in Spring Boot with Amazon SES SMTP Interface
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.mail.MessagingException;
@mmafrar
mmafrar / DefaultController.java
Created April 29, 2021 19:08
Sending emails in Spring Boot with Amazon SES SMTP Interface
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.mail.MessagingException;
import java.io.UnsupportedEncodingException;
@mmafrar
mmafrar / config.yml
Created May 26, 2021 18:05
Setting up continuous integration in Spring Boot with GitHub and CircleCI
# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
@mmafrar
mmafrar / DemoApplication.java
Created June 6, 2021 00:59
Deploying Spring Boot MVC with JSP project to AWS Elastic Beanstalk
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
@mmafrar
mmafrar / ContactServiceTest.java
Created June 28, 2021 17:53
Writing unit tests in Spring Boot with JUnit 5
package com.example.demo.service;
import com.example.demo.model.Contact;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;