You can have a preview here:
๐ My AWS EC2 Server
This guide provides step-by-step instructions to set up and launch the XM Blog application on your local machine. The application consists of a Spring Boot backend and a Vue.js frontend.
Before proceeding, ensure you have the following installed on your system:
- Homebrew: Package manager for macOS. Install Homebrew
- MySQL: Relational database management system.
- Redis: In-memory data structure store. Redis Documentation
- Java Development Kit (JDK): Version 1.8
- Node.js and npm: JavaScript runtime and package manager. Download Node.js
- Maven: Build automation tool for Java projects. Install Maven
Follow the steps below to set up and run the XM Blog application.
Create a new MySQL database named xm-blog with the character set utf8mb4 and collation utf8mb4_unicode_ci.
-
Access MySQL Command-Line Interface:
mysql -u your_username -p
Replace
your_usernamewith your MySQL username. You will be prompted to enter your password. -
Create the Database:
CREATE DATABASE `xm-blog` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
Exit MySQL:
EXIT;
Load the database schema from the xm-blog.sql file into the newly created xm-blog database.
-
Navigate to the Directory Containing
xm-blog.sql:cd path/to/your/sql/file -
Import the Schema:
mysql -u your_username -p xm-blog < xm-blog.sqlReplace
your_usernamewith your MySQL username. You will be prompted to enter your password.
Set up the Spring Boot backend project to use JDK 1.8.
-
Open the Project in Your IDE:
Open the
springbootproject in your preferred Integrated Development Environment (IDE) such as IntelliJ IDEA or Eclipse. -
Set JDK Version to 1.8:
-
IntelliJ IDEA:
- Go to
File>Project Structure>Project. - Set the
Project SDKto JDK 1.8. - Set the
Project language levelto8 - Lambdas, type annotations, etc.
- Go to
-
Eclipse:
- Right-click on the project >
Properties>Java Build Path>Libraries. - Ensure that JDK 1.8 is selected.
- Go to
Java Compilerand set theCompiler compliance levelto1.8.
- Right-click on the project >
-
-
Verify Maven Configuration:
Ensure that the
pom.xmlis set to use Java 1.8.<properties> <java.version>1.8</java.version> </properties>
-
Install Redis (macOS):
brew install redis
-
Start Redis Server:
brew services start redis
-
Verify Redis Installation:
redis-cli ping
Should return:
PONG -
Configure Redis in Spring Boot:
Update your
application.ymlwith Redis configuration:spring: redis: host: localhost port: 6379 database: 0 timeout: 1000 lettuce: pool: max-active: 8 max-wait: -1 max-idle: 8 min-idle: 0 cache: type: redis redis: key-prefix: xm-blog cache-null-values: false use-key-prefix: true
-
Add Redis Dependencies:
Add the following to your
pom.xml:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>
Configure the Spring Boot application to connect to the xm-blog MySQL database.
-
Locate
application.yml:The
application.ymlfile is typically located in thesrc/main/resourcesdirectory of your Spring Boot project. -
Update Database Connection Settings:
spring: datasource: url: jdbc:mysql://localhost:3306/xm-blog?useUnicode=true&characterEncoding=utf8mb4&serverTimezone=UTC username: your_username password: your_password jpa: hibernate: ddl-auto: update show-sql: true
- Parameters:
url: JDBC URL for the MySQL database.username: Your MySQL username.password: Your MySQL password.ddl-auto: Setting toupdateallows Hibernate to automatically update the database schema.show-sql: Enables logging of SQL statements.
Replace
your_usernameandyour_passwordwith your actual MySQL credentials. - Parameters:
This step involves launching both the Spring Boot backend and the Vue.js frontend.
-
Navigate to the Spring Boot Project Directory:
cd path/to/springboot -
Build and Run the Application:
-
Using Maven Wrapper:
./mvnw spring-boot:run
-
Using Maven Installed on Your System:
mvn spring-boot:run
Ensure you are in the root directory of the Spring Boot project when executing the above command.
-
-
Verify the Backend is Running:
By default, Spring Boot runs on port
8080. You should see logs indicating that the application has started successfully.
-
Navigate to the Vue.js Project Directory:
cd vue -
Install Dependencies:
npm install
This command installs all necessary packages listed in
package.json.
-
Start the Development Server:
npm run serve
-
Access the Frontend Application:
Once the development server is running, you can access the Vue.js application by navigating to
http://localhost:8080(or the port specified in the terminal output) in your web browser.
With both the Spring Boot backend and the Vue.js frontend running:
- Backend API: Accessible at
http://localhost:8080(default port). - Frontend Interface: Accessible at
http://localhost:8080or the port specified by the Vue.js development server.
Note: If both the backend and frontend are set to use the same port (8080), you may need to configure one of them to use a different port to avoid conflicts.
-
MySQL Issues:
- Ensure MySQL is running.
- Verify that the credentials in
application.ymlare correct. - Check if the
xm-blogdatabase exists and is properly configured.
-
Port Conflicts:
-
If port
8080is already in use, you can change the port in the Spring Bootapplication.yml:server: port: 8081
-
For Vue.js, you can change the port by modifying the
package.jsonscripts or using environment variables.
-
-
Dependency Errors:
-
For the backend, ensure all Maven dependencies are downloaded by running:
mvn clean install
-
For the frontend, ensure all npm packages are installed by running:
npm install
-
-
Application Not Starting:
- Check the console logs for any error messages.
- Ensure that the Java version is set to 1.8.
- Verify that all environment variables and configurations are correctly set.
-
Redis Connection Issues:
- Ensure Redis server is running:
redis-cli ping - Check Redis service status:
brew services list - Restart Redis:
brew services restart redis
- Ensure Redis server is running:
-
Redis Cache Not Working:
- Verify Redis configuration in
application.yml - Check Spring Boot logs for Redis-related errors
- Ensure
@EnableCachingannotation is present in your main application class
- Verify Redis configuration in
Contributions are welcome! Please follow these steps to contribute:
-
Fork the Repository.
-
Create a New Branch:
git checkout -b feature/YourFeatureName
-
Make Your Changes.
-
Commit Your Changes:
git commit -m "Add Your Feature" -
Push to the Branch:
git push origin feature/YourFeatureName
-
Create a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.