Code Monkey home page Code Monkey logo

crud-spring-boot-jpa-mysql's Introduction

CRUD-Spring-Boot-JPA-MySQL

CRUD Example of Spring-Boot-REST-JPA-MySQL (BookStore)

1. You can clone it from github by running following command

  $ git clone https://github.com/niteshsinghrajput/CRUD-Spring-Boot-JPA-MySQL.git

2. Import project into eclipse

  File -> Import -> Maven -> Existing Maven Projects -> Browse Project from cloned location

3. Right click on project in eclipse and then Maven -> Update Projects

4. Import src/main/java/resources/book.sql into MySQL database

5. Update database credential and other configuration into application.properties available in src/main/java/resources


spring.datasource.url=jdbc:mysql://localhost:3306/bookstore
spring.datasource.username=root
spring.datasource.password=
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=20
spring.datasource.tomcat.min-idle=15

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE


6. Right click on Application.java file and run as Java Application

Once Sprint Boot Application will be started successfully then we

can call following Endpoints by using POSTMAN

7. To get list of books call following endpoint with GET Request

  http://localhost:8080/bookservice/books

8.To Create New Book use following url with POST Request

  http://localhost:8080/bookservice/books

set content type as in header as application/json

set request body as raw with JSON payload

  {
    "name": "C++",
    "author": "Nitesh",
    "publication": "Rajput Publication",
    "category": "Computer Programming",
    "pages": 1500,
    "price": 240
  }

9.To get a particular book, use following url with GET request type in postman

  http://localhost:8080/bookservice/books/<id>

10.To update Book in database, use following url with PUT request type in postman

	http://localhost:8080/bookservice/books/<id>

set content type as in header as application/json

set request body as raw with JSON payload

 {
    "name": "C++",
    "author": "Nitesh",
    "publication": "Rajput Publication",
    "category": "Computer Programming",
    "pages": 1500,
    "price": 240
  }

11.To delete a particular Book from database, use following url with DELETE request type in postman

  http://localhost:8080/bookservice/books/<id>

Note - Replace with actual id

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.