Coder Social home page Coder Social logo

employee-demo's Introduction

Employee demo example by using Spring Boot, JPA, FlywayDB, MySQL, Swagger.

Requirements

  1. Java - 1.8.x

  2. Maven - 3.x.x

  3. MySQL - 5.x.x

  4. FlywayDB Plugin

  5. Swagger UI & API

Setup

1. Clone the application

https://github.com/tamilsmani/employee-demo.git

2. Create Mysql database

create database employee_demo

3. Update mysql username and password as per your installation and it is externalize outside

  • create application.properties anywhere in your disk and add below entries and update respective value. Note: Sample file kept inside "employee-demo\src\main\resources\application.properties" for your reference
database.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
database.driver.name=com.mysql.cj.jdbc.Driver
database.db.url=jdbc:mysql://localhost:3306/empolyee_demo
database.schema.user.name=root
database.scheam.password=root

employee.demo.username=admin
employee.demo.password=admin

4. Now migrate DB using Flyway plugin

cd employee-demo
mvn flyway:migrate -Ddb.user=root -Ddb.password=root -Ddb.url=jdbc:mysql://localhost:3306/employee_demo

5. Package your project - Runs with test case

mvn clean install -Dapp.home=c:/temp

6. Run employee-demo application

java -Dapp.home=C:/temp -Dserver.servlet.context-path=/employee-demo -Dspring.flyway.enabled=false -jar target/employee-demo-0.0.1-SNAPSHOT.jar

7. Swagger API - Details

http://localhost:8080/employee-demo/swagger-ui.html

8. API - Details

Create new employee

curl -X POST -H "Content-Type:application/json" -H "Authorization: Basic YWRtaW46YWRtaW4=" -d '{
  "firstName": "Tamil",
  "lastName": "Selvan",
  "gender": "MALE",
  "dateOfBirth": "06-06-1980",
  "department": {
    "code": "DPHY"
  }
}' http://localhost:8080/employee-demo/api/v1/employee/create
Load all employees order by first name

curl -v -s -H "Authorization: Basic YWRtaW46YWRtaW4=" http://localhost:8080/employee-demo/api/v1/employee/loadAll

employee-demo's People

Contributors

tamilsmani avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.