Jedis - Web Application Edition
Demonstrates using a jedis client in a web application. For more usage, refer to dawdler-client-plug-jedis.
1. Download and Run
Download the sample dawdler-tutorial.zip.
After extracting it, go into the jedis-single-web directory.
Start redis and configure redis.properties.
Run the main method of UserWebApplication.java.
@DawdlerBootApplication
public class UserWebApplication {
public static void main(String[] args) throws Throwable {
DawdlerWebApplication.run(UserWebApplication.class, args);
}
}
1.1 Configuration Files
1.1.1 redis.properties
The redis connection configuration can also be stored in the unified configuration center.
For related configuration, refer to dawdler-jedis-core.
1.2 Running as a Jar
Run
mvn clean package
to get jedis-single-web-0.0.1-jdk25-SNAPSHOT-all.jar
Then run
java -jar jedis-single-web-0.0.1-jdk25-SNAPSHOT-all.jar
1.3 Verification
Call the POST endpoint http://localhost:8085/user/add with postman to add a user.
The body is:
{"id":1,"username":"srchen","password":null,"email":"jackson.song@dawdler.club","phone":null,"created_at":null,"updated_at":null}
Then visit http://localhost:8085/user/info?id=1 with postman or a browser.