Skip to content

Repository files navigation

Spring-WebServer-Oracle

A backend practice project built with Java 17, Spring Boot 3, Oracle DB, and MyBatis, including JWT-based authentication, RESTful APIs, Spring Batch, and MinIO (S3 compatible) integration. The project provides Docker-based local environments for Oracle XE and MinIO.


1. Project Overview

This repository is a monolithic backend application created for studying and practicing:

  • Spring Boot 3 project structure and modern Java development
  • Oracle DB integration using MyBatis (XML mapper style)
  • Stateless JWT Authentication using Spring Security
  • RESTful API design for multiple business domains
  • SQL-based schema and sample data initialization
  • File storage integration using MinIO (S3-compatible)
  • Basic batch job examples using Spring Batch

Application default endpoint: http://localhost:8090


2. Tech Stack

Language

  • Java 17

Frameworks

  • Spring Boot 3.3.4
  • Spring Web (REST Controller)
  • Spring Security + JWT Authentication (jjwt 0.11.5)
  • Spring Validation
  • Spring AOP
  • Spring Quartz (Scheduling)

Database & Storage

  • Oracle XE 11g (via Docker)
  • MyBatis 3.0.3 (Mapper + XML)
  • MinIO (S3-compatible, RELEASE.2025-07-23)
  • AWS SDK v2 for S3 integration

Build & Tools

  • Gradle 8.x
  • Docker / Docker Compose 3.3
  • Swagger / Springdoc OpenAPI 2.6.0
  • Lombok 1.18.34
  • CircleCI (example CI configuration)

3. Project Structure

Spring-WebServer-Oracle/
├── .circleci/ # CircleCI CI/CD configuration
├── init/
│ └── table.sql # Oracle DB schema & sample data
├── src/
│ └── main/
│ ├── java/com/singer/
│ │ ├── SpringWebServerOracleApplication.java
│ │ ├── application/
│ │ │ ├── controller/ # REST API Controllers
│ │ │ │ ├── comm/ # Auth, Common, Stream
│ │ │ │ ├── sb/ # Video Board (SB01, SB02)
│ │ │ │ ├── sf/ # File Board (SF01, SF02)
│ │ │ │ ├── sm/ # User/Memo (SM01, SM02, SMI1)
│ │ │ │ ├── sr/ # Restaurant Board (SR01-SR03)
│ │ │ │ └── sv/ # Vote Board (SV01, SV02, SV04)
│ │ │ ├── dto/ # Request/Response DTOs
│ │ │ └── service/ # Business Logic Services
│ │ ├── common/
│ │ │ ├── bean/ # Bean Configurations
│ │ │ ├── exception/ # Custom Exceptions & Handlers
│ │ │ └── util/ # Utility Classes
│ │ ├── domain/
│ │ │ ├── dao/ # MyBatis DAO Interfaces
│ │ │ └── entity/ # Domain Entities
│ │ └── infrastructure/
│ │ ├── aop/ # AOP Logging Advice
│ │ ├── batch/ # Spring Batch Jobs
│ │ ├── config/ # OpenAPI, S3 Config
│ │ ├── security/ # JWT & Security Config
│ │ └── util/ # S3 Utility
│ └── resources/
│ ├── application.yml # Application Configuration
│ └── mappers/ # MyBatis XML Mappers
├── build.gradle # Gradle Build Configuration
├── docker-compose.yml # Docker Services (Oracle, MinIO)
└── README.md

4. Main Features

4.1 JWT Authentication & Authorization

The project implements a token-based login system with:

  • Stateless session handling
  • JWT token generation & validation
  • Public endpoints vs secure endpoints
  • Custom authentication filter

Authentication Flow

Login

  • POST /api/v1/auth/login
  • Request Body:
{
"username": "admin",
"password": "admin1234"
}

Or the userid/passwd combination from the SM01 table in the DB (in production)

  • Response:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Protected API Calls

Add the JWT to the HTTP header for all protected API calls, as follows:

Authorization: Bearer {accessToken}

Swagger

  • Swagger UI: http://localhost:8090/swagger-ui/index.html
  • OpenAPI: http://localhost:8090/v3/api-docs

4.2 Business Modules

This project includes several sample business modules:

ModuleTableDescription
User ManagementSM01, SMP1, SMI1, SME1User accounts, profile photos, user info, user events
Video BoardSB01, SB02, SBV1, SBG1Video posts, comments, video paths, like/hate logs
File BoardSF01, SF02, SFG1, SFD1File posts, comments, like logs, download logs
Vote BoardSV01, SV02, SV03, SV04, SVG1Vote posts, options, votes, comments, like logs
Restaurant BoardSR01, SR02, SR03, SRP1, SRG1Restaurant posts, ratings, comments, photos, like logs
MemoSM02Personal memo/notes
Code ManagementCODE_GRP, CODE, MENUSystem codes, menus

4.3 MinIO (S3-compatible) File Storage Integration

The project supports local S3-style storage using MinIO:

  • File upload / download example API
  • Configurable bucket name, access key, endpoint URL
  • Same pattern used for AWS S3 → easily extendable

4.4 AOP Logging

  • Method tracing and performance measurement
  • Request/response logging
  • Implemented in AopAdvice.java

5. API Endpoints

Authentication

MethodEndpointDescription
POST/api/v1/auth/loginLogin and get JWT token

User Management (SM)

MethodEndpointDescription
GET/api/v1/sm01/{nowPage}Get user list
GET/api/v1/sm01/one/{userid}Get user detail
POST/api/v1/sm01Create user
PUT/api/v1/sm01/{userid}Update user
DELETE/api/v1/sm01/{userid}Delete user

Video Board (SB)

MethodEndpointDescription
GET/api/v1/sb01/{nowPage}Get video post list
GET/api/v1/sb01/one/{seq}Get video post detail
POST/api/v1/sb01Create video post
DELETE/api/v1/sb01/{seq}Delete video post
PATCH/api/v1/sb01/like/{seq}Like video post
GET/api/v1/sb02/{seq01}/{nowPage}Get comments
POST/api/v1/sb02Create comment

File Board (SF)

MethodEndpointDescription
GET/api/v1/sf01/{nowPage}Get file post list
POST/api/v1/sf01Create file post (with upload)
DELETE/api/v1/sf01/{seq}Delete file post
GET/api/v1/sf02/{seq01}/{nowPage}Get comments

Vote Board (SV)

MethodEndpointDescription
GET/api/v1/sv01/{nowPage}Get vote list
GET/api/v1/sv01/one/{seq}/{recall}Get vote detail
POST/api/v1/sv01Create vote
PUT/api/v1/sv01/sv01/{seq}Update vote
DELETE/api/v1/sv01/{seq}Delete vote
PATCH/api/v1/sv01/like/{seq}Like vote
POST/api/v1/sv02Submit vote option

Restaurant Board (SR)

MethodEndpointDescription
GET/api/v1/sr01/{nowPage}Get restaurant list
GET/api/v1/sr01/one/{seq}Get restaurant detail
POST/api/v1/sr01Create restaurant post
DELETE/api/v1/sr01/{seq}Delete restaurant post
POST/api/v1/sr02Rate restaurant
GET/api/v1/sr03/{seq01}/{nowPage}Get comments

Common

MethodEndpointDescription
GET/api/v1/comm/code/{codegrp}Get codes by group
GET/api/v1/comm/menuGet menu list

6. Database Schema

Entity Relationship

SM01 (User) ──┬── SMP1 (Profile Photo)
├── SMI1 (User Info)
├── SME1 (User Event)
├── SM02 (Memo)
├── SB01 (Video Post) ──┬── SB02 (Comment)
│ ├── SBV1 (Video Path)
│ └── SBG1 (Like Log)
├── SF01 (File Post) ──┬── SF02 (Comment)
│ ├── SFG1 (Like Log)
│ └── SFD1 (Download Log)
├── SV01 (Vote Post) ──┬── SV02 (Option) ── SV03 (Vote)
│ ├── SV04 (Comment)
│ └── SVG1 (Like Log)
└── SR01 (Restaurant) ──┬── SR02 (Rating)
├── SR03 (Comment)
├── SRP1 (Photo)
└── SRG1 (Like Log)

Key Tables

TableDescriptionPrimary Key
SM01User accountsuserid
SB01Video board postsseq (auto-increment)
SF01File board postsseq (auto-increment)
SV01Vote board postsseq (auto-increment)
SR01Restaurant board postsseq (auto-increment)
CODE_GRPCode group mastercodegrp
CODECode detailcodegrp + codecd
MENUSystem menumenucd

7. Prerequisites

Install the following:

  • JDK 17+
  • Docker & Docker Compose
  • Gradle 8.x (or use included wrapper)
  • 4GB+ RAM recommended for Oracle XE Docker container

Also ensure:

  • Port 11521 (Oracle), 9000 (MinIO API), 9001 (MinIO Console) are not occupied
  • Your machine has enough memory for Oracle to start properly

8. Running the Project

8.1 Start Oracle & MinIO via Docker Compose

From project root:

docker-compose up -d

This starts:

  • Oracle XE 11g on port 11521 (internal 1521)
  • MinIO Server on port 9000 (API) and 9001 (Console)
  • Auto bucket creation (s3-storage bucket)

Wait for Oracle to fully initialize (check logs with docker-compose logs -f oracle).

8.2 Start the Spring Application

Using Gradle wrapper:

./gradlew clean bootRun

Or build JAR:

./gradlew clean build
java -jar build/libs/Spring-WebServer-Oracle-0.0.1-SNAPSHOT.jar

App starts at: http://localhost:8090


9. Configuration

application.yml Key Settings

PropertyDefaultDescription
server.port8090Application port
spring.datasource.urljdbc:oracle:thin:@127.0.0.1:11521/xeOracle connection URL
spring.datasource.usernameinsungDB username
spring.datasource.password12345678DB password
aws.s3.endpointhttp://localhost:9000MinIO endpoint
aws.s3.bucketNames3-storageS3 bucket name
aws.s3.accessminioadminMinIO access key
aws.s3.secretminioadminMinIO secret key
jwt.secret(base64 encoded)JWT signing key
jwt.expiration-seconds3600Token expiration (1 hour)

Docker Services

ServiceImagePortsPurpose
oracleoracleinanutshell/oracle-xe-11g11521:1521Oracle XE Database
miniominio/minio:RELEASE.2025-07-239000, 9001S3-compatible storage
createbucketsminio/mc-Auto bucket creation

10. API Documentation (Swagger / OpenAPI)

Swagger UI available at:

http://localhost:8090/swagger-ui/index.html

OpenAPI JSON:

http://localhost:8090/v3/api-docs

Testing Secured Endpoints

  1. Login via POST /api/v1/auth/login
  2. Copy the accessToken from response
  3. Click Authorize in Swagger UI
  4. Enter: Bearer {accessToken}

Test Credentials

UsernamePasswordRole
adminadmin1234Administrator
user01pass01Normal User

11. MinIO Console

Access MinIO web console:

http://localhost:9001

Login credentials:

  • Username: minioadmin
  • Password: minioadmin

12. Troubleshooting

Oracle Container Issues

# Check Oracle logs
docker-compose logs oracle
# Restart Oracle container
docker-compose restart oracle
# Reset Oracle data (caution: deletes all data)
docker-compose down -v
docker-compose up -d

Connection Refused

  • Ensure Docker containers are running: docker-compose ps
  • Wait for Oracle initialization (can take 2-3 minutes on first start)
  • Check if ports are available: netstat -an | grep 11521

JWT Token Expired

  • Default expiration is 1 hour
  • Re-login to get a new token

13. Development Notes

Adding New API Module

  1. Create Entity in domain/entity/{module}/
  2. Create DAO interface in domain/dao/{module}/
  3. Create MyBatis mapper XML in resources/mappers/
  4. Create DTOs in application/dto/{module}/
  5. Create Service in application/service/{module}/
  6. Create Controller in application/controller/{module}/

Code Conventions

  • Entity naming: {MODULE}{SEQ}Entity.java (e.g., SB01Entity.java)
  • Mapper naming: {MODULE}{SEQ}VoMapper.xml (e.g., SB01VoMapper.xml)
  • API prefix: /api/v1/{module}

14. License

This project is for educational and practice purposes.

Releases

Packages

Used by

Contributors

Languages