This is a simple web application built with Java, Spring Boot, and Redis. The application increments a counter every time the home page is visited and displays the current visitor count.
- Visitor Counter: Increments and displays the number of visits to the home page.
- Redis Integration: Uses Redis to store and manage the visitor count, ensuring persistence across application restarts.
- Spring Boot: The application is built using Spring Boot, making it easy to run and deploy.
Before you begin, ensure you have the following installed on your system:
- Java 11 or higher
- Maven for dependency management and running the application
- Redis server
git clone https://github.com/lyfe691/View_Counter.git
cd View_Counter
Make sure Redis is installed and running on your machine. The application is configured to connect to Redis on localhost
at port 6379
by default.
If you dont have redis installed do this:
You can't run redis on default on windows, you'll have to use a VM or the Windows Subsystem for Linux (WSL). This is how you can install it:
- Powershell (Administator) Run this and restart.
wsl --install
- Now that you have WSL installed you can open your terminal and open a new tab as ubuntu or type
wsl
and enter the following commands:
sudo apt-get update
sudo apt-get install redis
- Start Redis
redis-server
- Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Redis
brew install redis
- Start Redis
brew services start redis
- Install Redis
sudo apt-get update
sudo apt-get install redis
- Start Redis
redis-server
Compile and package the application using Maven:
mvn clean install
Start the Spring Boot application:
mvn spring-boot:run
Open your web browser and go to:
http://localhost:8080
Each time you refresh the page, the visitor counter will increment.
View_Counter/
│
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/redis/visitorcounter/
│ │ │ ├── VisitorCounterApplication.java # Main application class
│ │ │ └── VisitorCounterController.java # Controller handling the visitor count
│ │ └── resources/
│ │ └── application.properties # Redis configuration
│ └── test/ # Unit tests (if any)
│
├── pom.xml # Maven build file
└── README.md # Project documentation
- Java
- Spring Boot
- Redis
- Maven
This project is licensed under the MIT License. See the LICENSE file for details.