SpringBoot + MyBatis-Plus + Shiro + JWT Demo Project Overview and Deployment Guide
This article introduces a SpringBoot-based backend demo that integrates MyBatis-Plus, Apache Shiro, and JWT, outlines its custom annotations and security features, explains the request flow, and provides step‑by‑step instructions for setting up the database, configuring the environment, and running the application.
Background : Front‑back separation has become the standard for internet projects, and SpringBoot simplifies coding, configuration, and deployment, making it a popular micro‑service framework. The project also uses MyBatis‑Plus for enhanced CRUD operations, Apache Shiro for Java security, and JSON Web Tokens (JWT) for stateless authentication.
Project Features : 1) Custom @Log annotation records logs to the database. 2) Custom @Pass annotation skips authentication for specific endpoints. 3) Unified request body handling with JSONObject and a custom @ValidationParam annotation for null checks. 4) Passwords are encrypted with bcrypt. 5) Shiro annotations provide fine‑grained, button‑level permission control, and a custom @CurrentUser annotation retrieves the logged‑in user. 6) Spring AOP is used for declarative transactions and XSS protection. 7) Stateless login via POST returns a token and permission info, with empty response fields omitted.
Program Logic : 1) Users submit username and password to the /login endpoint via POST; a JWT token is returned on success, otherwise a 401 error page is shown. 2) Subsequent requests include the token in the Authorization header. 3) The server validates the token; failure also leads to a 401 page. 4) JWT handles authentication while Shiro handles authorization.
Running the Project : Clone the repository (requires JDK 1.8). Import the Maven project and select the liugh-parent pom. Create a MySQL database named liugh with UTF‑8 encoding and execute liugh.sql to initialize data. Update application-dev.properties with your MySQL credentials. Run SpringbootApplication.java from Eclipse/IDEA, or execute mvn clean package in the liugh-parent directory and then java -jar liugh-web/target/liugh-web.jar . Start a Redis service. Access the login API at http://localhost:8081/api/login using the credentials 13888888888/123456 , obtain the token, and call other APIs with the /api/v1 prefix.
Notes : Ensure the API URLs are prefixed with /api/v1 and install the Lombok plugin in your IDE to avoid compilation errors.
Conclusion : The project’s source code is fully commented, includes a custom startup banner, and can be obtained by following the public account and replying with the keyword “113”.
Java Architect Essentials
Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.