Giter Club home page Giter Club logo

spring_boot-jersey-jwt's Introduction

spring_boot-jersey-jwt

集成mongo,redis,spring boot,jersey,jwt,redisson,mybatis等app服务端一般用到的组件

运行

  1. 使用mongo和mysql,建议使用docker安装,mongo中可以手动建立一个名为user的collection,其中有个具有用户名和密码的文档
{ 
    "_id" : NumberLong(20000), 
    "_class" : "com.example.entity.mongo.User", 
    "userName" : "binglin", 
    "password" : "123456", 
    "roles" : [
        "user"
    ], 
    "version" : NumberInt(1)
}
  1. 直接运行main方法即可

测试,使用postman

  1. 获取token

    post http://localhost:8080/authentication body选择x-www-form-urlencoded username binglin password 123456 返回

    {
    

"authToken": "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJKZXJzZXktU2VjdXJpdHktQmFzaWMiLCJzdWIiOiJiaW5nbGluIiwiYXVkIjoidXNlciIsImV4cCI6MTQ3NTg5ODA0MiwiaWF0IjoxNDc1ODk3MTQ0LCJqdGkiOiIxIn0.sNeMZqAh6V3cXV9IYxIvydfoh0sTCAXsdCl1FcSBclA", "expires": "2016-10-08T03:40:42.863 UTC" }

2. 使用token访问rest接口
GET http://localhost:8080/users
在Headers 中添加
`Authorization Bearer "${上一步获取的token}"
返回mongo中的所有user文档

3. 实现组合接口功能
如

curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 35d5e900-65b6-a62b-b5eb-c82e0a761915" -d '[
{
"url": "/users/bean",
"method": "GET"
},
{
"url": "/books",
"method": "GET",
"param" : {
"name":""
}
}
]' "http://localhost:8080/combine"

接口会分别返回每个url对应的结果

[ { "url": "/books", "method": "GET", "entity": { "content": [ { "id": 2, "uuid": "11233", "name": "testName", "author": "binglin" }, { "id": 20000, "uuid": "11233", "name": "testName", "author": "binglin" }, { "id": 20001, "uuid": "11233", "name": "testName", "author": "binglin" }, { "id": 20002, "uuid": "9937374", "name": "testName", "author": "binglin" }, { "id": 20003, "uuid": "9937374", "name": "testName", "author": "binglin" }, { "id": 20004, "uuid": "9937374", "name": "testName", "author": "binglin" }, { "id": 20005, "uuid": "9937374", "name": "testName", "author": "binglin" }, { "id": 20006, "uuid": "11233", "name": "testName", "author": "binglin" } ], "last": true, "totalElements": 8, "totalPages": 1, "number": 0, "size": 10, "sort": null, "first": true, "numberOfElements": 8 }, "httpStatus": 200 }, { "url": "/users/bean", "method": "GET", "entity": [ { "id": 1, "name": "binglin", "password": "123256" }, { "id": 2, "name": "tom", "password": "123456" } ], "httpStatus": 200 } ]


## 
集成通用 Mapper 和 分页插件 Mybatis-PageHelper 集成
通用 Mapper https://github.com/abel533/Mapper)
Myabtis 分页插件 https://github.com/pagehelper/Mybatis-PageHelper

spring_boot-jersey-jwt's People

Contributors

binglinoioij avatar qiuming avatar

Watchers

James Cloos avatar  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.