Elasticsearch - Web Application Edition
Demonstrates using an elasticsearch client in a web application. For more usage, refer to dawdler-client-plug-es.
1. Download and Run
Download the sample dawdler-tutorial.zip.
After extracting it, go into the elasticsearch-single-web directory.
Start elasticsearch and configure elasticsearch.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);
}
}
Then visit http://localhost:8085/user/list?pageOn=1 with postman or a browser.
1.1 Configuration Files
1.1.1 elasticsearch.properties
The elasticsearch connection configuration can also be stored in the unified configuration center.
For related configuration, refer to dawdler-es-core.
1.2 Running as a Jar
Run
mvn clean package
to get elasticsearch-single-web-0.0.1-jdk25-SNAPSHOT-all.jar
Then run
java -jar elasticsearch-single-web-0.0.1-jdk25-SNAPSHOT-all.jar
1.3 Verification
After startup, visit http://localhost:8085/user/info?id=1.