A developer community named Nowcoder. Built using Spring Boot, Spring MVC, Thymeleaf, MyBatis, Redis and Kafka.
In order to switch the project to dev/prod mode, just open application.properties and change the value to the one you desire.
The project is developed under the IntelliJ Idea environment. For your best experience, I recommend to run the project using IntelliJ too.
Below are the necessary steps to install the technologies used in the project.
- Install Maven and add it to the system path.
- Install MySQL. Run init_data.sql and init_schema.sql to initialize the database with the tables and the mock data.
- Install Redis and add it to the system path.
- Install wkhtmltopdf and add it to the system path.
- Install Kafka. Add the path to its bin folder to your system path.
- Fill out secrets.properties with all the credentials like the link to your database.
Once all the installation and configuration steps are done, perform below steps before running the project:
- Go to your kafka installation directory, and then open config/server.directory. Change log.dirs to where your desired path to save the logs is.
- Similarly, open zookeeper.properties under the same directory, and change dataDir to where you wish the logs to be.
Now run the project:
- CD to your kafka directory, and run the following command to start the zookeeper server:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
- Similarly, run the command below to start the Kafka service:
.\bin\windows\kafka-server-start.bat .\config\server.properties
- Make sure that you run the project using JDK 11.
Some preparation steps:
-
Install Maven, MySQL, Redis, Tomcat, Kafka and Nginx. Also make sure to add mvn and tomcat to PATH.
-
Start Tomcat
cd %tomcat installation directory%/bin
./startup.sh
-
Start Kafka server
a.
cd %kafka installation directory%
b.
sudo bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
c.
sudo nohup bin/kafka-server-start.sh config/server.properties 1>/dev/null 2>&1 &
d. Make sure to test the server using the command
bin/kafka-topics.sh --list --bootstrap-server %your internal ip%:9092
-
Start Nginx server
a. Open /etc/nginx/nginx.conf. In the http section, attach the following code:
upstream myserver { server 127.0.0.1:8080 max_fails=3 fail_timeout=30s; } server { listen 80; server_name %Your external IP%; location / { proxy_pass http://myserver; } }
b. Start the server.
systemctl start nginx
This project classifies users into three groups: normal user, admin and moderator. An admin is allowed to delete posts, query website data like beans and logs at /actuator, and calculate DAU and UV at /data. A moderator is allowed to pin or mark a post as feature. A normal user is granted access to all other functionalities.
Sample moderator account: nowcoder22 123456
Sample admin account: nowcoder11 123456