A simple, full-stack blog application built with Spring Boot that allows users to create, read, update, and delete blog posts. This application demonstrates modern Java web development practices using Spring Boot, JPA, Thymeleaf, and Bootstrap.
- CRUD Operations: Create, Read, Update, and Delete blog posts
- Responsive Design: Bootstrap-powered UI that works on all devices
- Database Integration: H2 in-memory database with JPA/Hibernate
- Web Interface: Clean, intuitive web interface for managing blog posts
- Real-time Updates: Immediate reflection of changes in the web interface
- Backend: Spring Boot 2.1.6
- Database: H2 Database (in-memory)
- ORM: Spring Data JPA with Hibernate
- Frontend: Thymeleaf templates with Bootstrap 3.3.7
- Build Tool: Maven
- Java Version: Java 8
Before running this application, make sure you have the following installed:
- Java 8 or higher
- Maven 3.6+ (or use the included Maven wrapper)
- Git (for cloning the repository)
git clone <repository-url>
cd JavaBlogPostYou can run the application using Maven wrapper (recommended) or Maven directly:
Using Maven Wrapper:
# On Windows
./mvnw.cmd spring-boot:run
# On Unix/Linux/Mac
./mvnw spring-boot:runUsing Maven:
mvn spring-boot:runOnce the application starts successfully, you can access it at:
- Main Application: http://localhost:8080
- H2 Database Console: http://localhost:8080/console
- JDBC URL:
jdbc:h2:mem:testdb - Username:
sa - Password: (leave empty)
- JDBC URL:
src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── derinsblog/
│ │ ├── DerinsBlogApplication.java # Main Spring Boot application class
│ │ └── blogpost/
│ │ ├── BlogPost.java # JPA Entity for blog posts
│ │ ├── BlogPostController.java # REST Controller handling web requests
│ │ └── BlogPostRepository.java # Spring Data JPA Repository
│ └── resources/
│ ├── application.properties # Application configuration
│ ├── static/
│ │ └── css/
│ │ └── standard.css # Custom CSS styles
│ └── templates/
│ ├── fragments/
│ │ └── navbar.html # Reusable navigation bar fragment
│ └── blogpost/
│ ├── index.html # Blog posts listing page
│ ├── new.html # Create new blog post form
│ ├── edit.html # Edit existing blog post form
│ ├── show.html # Display individual blog post
│ └── result.html # Confirmation page after operations
└── test/
└── java/
└── com/
└── derinsblog/
└── DerinsBlogApplicationTests.java # Unit tests
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Display all blog posts (homepage) |
| POST | / |
Create a new blog post |
| GET | /blogpost/new |
Show form to create new blog post |
| POST | /blogpost/new |
Create new blog post from form |
| GET | /blogpost/{id} |
Display specific blog post |
| GET | /blogpost/edit/{id} |
Show form to edit blog post |
| PUT | /blogpost/{id} |
Update existing blog post |
| DELETE | /blogpost/{id} |
Delete blog post |
The application uses a simple BlogPost entity with the following fields:
| Field | Type | Description |
|---|---|---|
id |
Long | Primary key (auto-generated) |
title |
String | Blog post title |
author |
String | Author name |
blogEntry |
String | Blog post content |
The application features a clean, responsive interface built with:
- Bootstrap 3.3.7: For responsive design and UI components
- Thymeleaf: Server-side template engine for dynamic content
- Custom CSS: Additional styling in
standard.css - Navigation Bar: Reusable fragment for consistent navigation
- Homepage (
/): Lists all blog posts with options to view, edit, or delete - New Post (
/blogpost/new): Form to create new blog posts - View Post (
/blogpost/{id}): Display individual blog post details - Edit Post (
/blogpost/edit/{id}): Form to modify existing blog posts - Result Page: Confirmation page after successful operations
The application is configured through src/main/resources/application.properties:
# H2 Database Console Configuration
spring.h2.console.enabled=true
spring.h2.console.path=/console
# Database Platform
spring.datasource.platform=h2Run the test suite using Maven:
# Using Maven wrapper
./mvnw test
# Using Maven
mvn testTo build a production-ready JAR file:
# Using Maven wrapper
./mvnw clean package
# Using Maven
mvn clean packageThe JAR file will be created in the target/ directory and can be run with:
java -jar target/DerinsBlog-0.0.1-SNAPSHOT.jar- Spring Boot DevTools: Automatic restart and live reload during development
- H2 Console: Web-based database management interface
- Actuator: Production-ready features for monitoring and managing the application
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
Derin Joseph
- Portfolio: derinjoseph.com
-
Port 8080 already in use: Change the port in
application.properties:server.port=8081 -
Java version issues: Ensure you're using Java 8 or higher:
java -version
-
Maven wrapper permissions: On Unix systems, make the wrapper executable:
chmod +x mvnw
- Spring Boot Documentation
- Spring Data JPA Documentation
- Thymeleaf Documentation
- Bootstrap Documentation
Happy Blogging! 🎉