Redis has several Java clients, but three are officially recommended: Jedis, Lettuce, and Redisson. The Spring framework provides integration with these clients through Spring Data Redis, and Spring Boot further simplifies the process with the spring-boot-starter-data-redis dependency.

Using Jedis Client

Step 1: Add Jedis Dependency
To start, create a Maven project and add the following dependency:

1
2
3
4
5
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.0</version>
</dependency>
Read more »

String Operations

Common commands for string operations in Redis:

  • SET key value: Sets the value of a specified key.
    • Example: 127.0.0.1:6379> set age 20
    • The value set using the SET command is always stored as a string.
    • If the key already exists, the value will be updated; if the key does not exist, a new key-value pair will be created.
  • GET key: Retrieves the value of a specified key.
    • Example: 127.0.0.1:6379> get age
  • SETEX key seconds value: Sets the value of a specified key and its expiration time in seconds (commonly used for storing verification codes).
  • SETNX key value: Sets the value of a key only if the key does not already exist (commonly used for distributed locks).

Hash Operations

Redis hashes are mapping tables of string-type fields and values, particularly suitable for storing objects.

Read more »

Starting the Service

Method 1: Start Redis Server Directly

Navigate to the /usr/local/redis-5.0.9/src/ directory (the src folder under your Redis installation path) and execute:

1
./redis-server

Navigate to the /usr/local/redis-5.0.9/ directory and execute:

1
src/redis-server ./redis.conf

Stopping the Service

To stop the service, press Ctrl + C in the service terminal.

Read more »

Checking for Existing MySQL Installations

First, check if MySQL is already installed on the current system.

  • rpm -qa: Lists all installed software on the system (qa means query all).
  • rpm -qa | grep mysql: Finds installed software containing “mysql” in its name.
  • rpm -qa | grep mariadb: Finds installed software containing “mariadb” in its name.

Note: If MariaDB is installed, it must be uninstalled first; otherwise, the MySQL installation will fail.

Uninstall command:

1
rpm -e --nodeps package_name

For example:

1
rpm -e --nodeps mariadb-libs-xxxxxxx

Steps to Install and Configure MySQL

1. Download MySQL

Download the MySQL 8.0.31 ARM64 version (for macOS M2 chip):

Download Link

File name: mysql-8.0.31-linux-glibc2.17-aarch64.tar.gz

2. Upload and Extract MySQL

  1. Use sftp to upload the installation package to the Linux server:

    1
    put /Users/kathy/Downloads/linux-software/mysql-8.0.31-linux-glibc2.17-aarch64.tar.gz /root/
Read more »

Manual Deployment

1. Package the Project

Develop a Spring Boot project in IDEA and package it as a JAR file.
Use the Maven tool on the right-hand side of IDEA and click package to build the project.
The JAR file will be located in target/helloworld-0.0.1-SNAPSHOT.jar.

2. Upload the JAR File to the Linux Server

  1. Create a directory on the Linux server to store the JAR file:

    1
    mkdir /usr/local/app
  2. Open a terminal and create a remote connection:

    • Use the shell menu to open a new remote connection.
    • Select Secure File Transfer (sftp) and add the remote server’s IP address (e.g., 192.168.50.158).
    • Enter the server’s username (e.g., root) and connect by providing the server’s password.
  3. Upload the file:

    1
    put /Users/kathy/Desktop/workspace_idea/helloworld/target/helloworld-0.0.1-SNAPSHOT.jar /usr/local/app/

    This command uploads the JAR file to /usr/local/app/.

3. Start the Spring Boot Application

On the Linux terminal, navigate(cd) to the directory and execute the following command:

1
java -jar helloworld-0.0.1-SNAPSHOT.jar
Read more »

Common Commands

Command English Function
ls list View the contents (files/directories) of the current directory
pwd print work directory View the current directory
cd [directory name] change directory Switch directories
touch [file name] touch Create a new file if it does not exist
mkdir [directory name] make directory Create a directory
rm [file name] remove Delete a specified file

Usage Tips:

  • Use the Tab key for auto-completion.
  • Press the Tab key twice to get operation suggestions.
  • Use the up and down arrow keys to quickly recall previously used commands.
  • Use the clear command or the Ctrl + L shortcut to clear the screen.
    Read more »

1. Uploading a Project Created in IDEA to a Remote Repository

1.1 Initialize a Local Repository

Create a Maven project in IDEA and manage it with a local Git repository:

  1. Create a Maven project in IDEA.
  2. Go to the top menu: VCS (Version Control) -> Create Git Repository.
  3. Select your project directory. The directory will become a repository, and Git icons will appear at the top of the IDEA interface.

1.2 Associate the Local Repository with a Remote Repository on Gitee

  1. Right-click the project name -> Git -> Manage Remotes.
  2. In the Git Remotes dialog, click the + button.
  3. Enter the remote name (e.g., origin) and URL (e.g., https://gitee.com/kxzhu93/git_test.git) to associate the local repository with the remote one.
Read more »

Global Git Settings

After installing Git (macOS users can install Xcode), you need to configure user information (username and email). This user information will be used for every Git commit.

Setting User Information

Open the terminal and enter the following commands:

1
git config --global user.name "YourUsername"

Example:

1
git config --global user.name "kxzhu"
1
git config --global user.email "YourEmail"

Example:

1
git config --global user.email "xxxxxx@qq.com"

Viewing Configuration Information

1
git config --list

Getting a Git Repository

To use Git for version control, you first need to obtain a Git repository. There are two ways to do this:

Read more »

在实现MySQL主从复制时(具体见MySQL主从复制 ),我们需要提前准备好两台服务器,分别安装MySQL并启动服务。由于是学习阶段,为了方便,我们可以采用克隆虚拟机的方式准备2台服务器。以下是步骤:

1、虚拟机关机

2、拍快照。在顶部菜单栏中,点击“虚拟机”(Virtual Machine),然后选择“拍摄快照”(Take Snapshot)。

3、克隆。在顶部菜单栏中,点击“虚拟机”(Virtual Machine),然后选择“完整克隆”。

图片

然后就会出现centOS9的克隆窗口

4、两台虚拟机分别开机,登录后,输入命令ip addr,记录两台虚拟机的ip

5、两台虚拟机分别输入命令sudo dmidecode -s system-uuid,记录两台虚拟机的uuid

6、修改网卡配置文件的uuid和ipaddr

vim /etc/sysconfig/network-scripts/ifcfg-ens160

(注:centOS7、8网卡设备的配置文件都叫ens33,centOS9网卡设备的配置文件叫ens160)

原始虚拟机ens-160网卡配置文件改为:

Read more »

This blog is based on the video course “Reggie Takeout” by Black Horse Programmers. It summarizes course notes, related knowledge points, and potential solutions to issues. Additionally, it includes features not implemented in the course for your reference. The notes are comprehensive and well-organized, aiming to help you in learning and understanding this takeout project.

For the full project notes, visit: Food Delivery System Notes Collection

Problem Description:

  • Developers are responsible for both frontend and backend code development, leading to unclear division of tasks.
  • Low development efficiency.
  • Frontend and backend code are mixed in a single project, making management difficult.
  • High skill requirements for developers, making recruitment challenging.
    Read more »
0%