- Oauth2 Authorization Server
Oauth2 Authorization Server
Content
OAuth2 Authorization Server with Spring Boot 3 and Java 24
Prerequisites
- Java 24 should be installed -->
export JAVA_HOME=$(/usr/libexec/java_home -v 24) - Maven should be installed
- Docker should be installed
- Postman can be installed
How to Run and Test
- Run
export DEEPSEEK_API_KEY=your_api_key_herecommand to set DeepSeek API key - Run
docker-compose up -dcommand to run necessary services - Run
mvn testormvn clean installormvn clean packageor./mvnw clean installcommand to run all the tests - Run
mvn spring-boot:runcommand to run the application - Import the followings to test in Postman
- Swagger: http://localhost:9000/swagger-ui/index.html
- Click
Authorizeand enter the following credentials client_id:clientclient_secret:secret- Use one of the following default values to log in http://localhost:9000/login
- username:
Developerpassword:password - username:
Adminpassword:password - username:
Userpassword:password
- username:
- Click
- Actuator: http://localhost:9000/actuator/
- Database credentials
url:jdbc:mariadb://localhost:3306/oauth2_authorization_serverusername:mb_testpassword:test
- Redis
host:localhostport:6379
- Redis Insight: http://localhost:5540/
- Click
Add Redis database Connection URL-->redis://default@host.docker.internal:6379- Click
Add Database 
- Click
- Ollama
- http://localhost:3000/ sign up for an account for local environment
- Search for
mxbai-embed-largeand download it if it does not exist - Search for
deepseek-r1:7band download it if it does not exist
Debugging Spring Boot Tests in IntelliJ IDEA
- Run one of the below commands in the terminal
mvn test -Dmaven.surefire.debug- If port 5005 is already in use, you can specify a custom port
mvn test -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
- Open IntelliJ IDEA
- Go to
Run > Attach to Process(or use shortcut)- Windows/Linux:
Ctrl + Alt + 5 - Mac:
Cmd + Alt + 5
- Windows/Linux:
- Select the Java process running your tests
- The test will pause until you connect your debugger. Once connected, you can use breakpoints and step through your code.
How to Run and Test Native Image with GraalVM
- Java 24 GraalVM edition should be installed
- Run
docker-compose up -dcommand to run necessary services - Run
./mvnw -Pnative native:compileor./mvnw -Pnative native:compile -DskipTestscommand to build the native image - Run
./target/oauth2-authorization-servercommand to run the native image - Install Grype (OPTIONAL)
- Run
native-image-inspect ./target/oauth2-authorization-server-0.0.1 | grype -vcommand to scan vulnerabilities
- Run
- Run
native-image-inspect ./target/oauth2-authorization-server-0.0.1 >output.jsoncommand and openoutput.jsonor visit http://localhost:9000/actuator/sbom/native-image to inspect all libraries, methods etc. used in the native image - Run
open ./target/oauth2-authorization-server-build-report.htmlto see build report - Use Swagger UI to test the application
Spring Boot with CRaC(Coordinated Restore at Checkpoint) by Creating Ready to Restore Container Image.
- Warning: for real projects make sure to not leak sensitive data in CRaC files since they contain a snapshot of the memory of the running JVM instance.
- Checkpoint
- Run
on demand checkpoint/restore of a running application
with:
./docs/scripts/checkpoint.sh - Run
an automatic checkpoint/restore at startup
with:
./docs/scripts/checkpointOnRefresh.sh
- Run
on demand checkpoint/restore of a running application
with:
- Restore
- Restore the application with:
./docs/scripts/restore.sh
- Restore the application with:
- Use Swagger UI to test the application
How to Run and Test AI Models Locally with Docker Desktop Model Runner
- Requires: Docker Desktop 4.40 and later
- Run
docker-compose up -dcommand to run necessary services - Run
docker model pull ai/gemma3:4B-Q4_K_Mcommand to pull the model- Run
docker model run ai/gemma3:4B-Q4_K_Mcommand to run the model to test it from the command line (OPTIONAL)
- Run
Docker Desktop-->Settings-->Features in development-->Beta features-->Enable Docker Model Runner-->Enable host-side TCP support-->Apply & Restart- Run
mvn testormvn clean installormvn clean packageor./mvnw clean installcommand to run all the tests - Run
mvn spring-boot:runcommand to run the application - Use Swagger UI to test the application
References
- Spring Boot 3 Tutorial Security OAuth2 Spring Authorization Server Save login data to a database
- BCryptPasswordEncoderTests
- Getting started with Spring Boot AOT + GraalVM Native Images
- Welcome, GraalVM for JDK 24!🚀
- A vulnerability scanner for container images and filesystems Grype
- Introduction to Project CRaC: Enhancing Runtime Efficiency in Java & Spring Development
- Model Context Protocol (MCP)
- Ollama Installation with Docker Compose
- A Guide to Spring AI Advisors
- Testing LLM Responses Using Spring AI Evaluators
- Vector Databases
- Java + RAG: Create an AI-Powered Financial Advisor using Spring AI 💡
- Run AI Models Locally: Zero API Keys, Zero Fees with Docker Desktop Model Runner
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
ChatWiseThe second fastest AI chatbot™
Playwright McpPlaywright MCP server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
WindsurfThe new purpose-built IDE to harness magic
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Serper MCP ServerA Serper MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.



