Giter Site home page Giter Site logo

simple-springboot-demo's Introduction

simple-springboot-demo

This is a simplest spring boot project, just for practice Git, DevOps, etc. Free to use.

How to use

Download project

git clone https://github.com/eaxecloud/simple-springboot-demo.git

You need install lombok library on your IDE, or remove @Data annotation and add setter and getter methods in xyz.fullstacks.demo.domain.User.java

Run project

Example on STS.

Right click the project and show a context menu, then choose Run AS > Spring Boot App menu.

You can change port in $PROJECT/src/main/resources/application.yml

Access H2 database

Access http://localhost:8001/h2

username:sa

password: 123456

The H2 database is initialize a table and insert 2 records in to the table when project start.

Test project

  1. Query all users

    Access URL http://localhost:8001/user/ on Browser, PostMan, etc.

    OR

    curl http://localhost:8001/user/

    Output sample:

    [{"id":1,"name":"root","email":"[email protected]","age":20},{"id":2,"name":"Peter","email":"[email protected]","age":22}]
  2. Get user

    curl http://localhost:8001/user/1

    Sample ouput

    {"id":1,"name":"root","email":"[email protected]","age":20}
  3. Add user

    curl -H "Content-Type: application/json" -X POST -d '{"id":4,"name":"Tom","email":"[email protected]","age":24}' "http://localhost:8001/user/"

    Remind, if you run the curl command and post JSON data on Window OS, please using below format

    curl -H "Content-Type:application/json;charset=UTF-8" -X POST -d "{"""id""":4,"""name""":"""Tom""","""email""":"""[email protected]""","""age""":24}" "http://localhost:8001/user/"

    Otherwise, it will throw error like below, and add user fail.

    curl -H "Content-Type: application/json" -X POST -d '{"id":4,"name":"Tom","email":"[email protected]","age":24}' "http://localhost:8001/user/"
    {"timestamp":"2021-11-24T04:23:44.871+00:00","status":400,"error":"Bad Request","path":"/user/"}
  4. Update user

    curl -H "Content-Type:application/json" -X PUT -d "{"""id""":4,"""name""":"""Tom""","""email""":"""[email protected]""","""age""":18}" "http://localhost:8001/user/"
    {"id":4,"name":"Tom","email":"[email protected]","age":18}
  5. Delete user

    curl -X DELETE http://localhost:8001/user/4

simple-springboot-demo's People

Contributors

eaxecloud avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

xusongwei

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.