# apm-tutorial-java **Repository Path**: baihr/apm-tutorial-java ## Basic Information - **Project Name**: apm-tutorial-java - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-12 - **Last Updated**: 2026-05-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # apm-tutorial-java > 本项目修改自 [apm-tutorial-java-host](https://github.com/DataDog/apm-tutorial-java-host) ## 克隆项目 ```bash mkdir ~/workspace cd ~/workspace git clone https://gitee.com/baihr/apm-tutorial-java.git ``` ## 部署 OpenJDK11 ```bash cd /tmp wget https://mirrors.tuna.tsinghua.edu.cn/Adoptium/11/jdk/x64/linux/OpenJDK11U-jdk_x64_linux_hotspot_11.0.29_7.tar.gz sudo mkdir /usr/java sudo tar -xzvf OpenJDK11U-jdk_x64_linux_hotspot_11.0.29_7.tar.gz -C /usr/java ``` 编辑 `/etc/profile`,设置环境变量: ```bash export JAVA_HOME=/usr/java/jdk-11.0.29+7 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH ``` 执行 `source /etc/profile`,使 profile 文件生效后,执行 `java -version` 验证。 ## 运行程序 ```bash cd notes wget -O dd-java-agent.jar 'https://static.guance.com/dd-image/dd-java-agent.jar' ./scripts/mvn_instrumented_run.sh cd calendar wget -O dd-java-agent.jar 'https://static.guance.com/dd-image/dd-java-agent.jar' ./scripts/mvn_instrumented_run.sh ``` ## REST APIs ### Calendar Application ```bash # 返回一个随机日期 # GET /calendar # {"status":"success","date":"3/22/2022"} curl "http://localhost:9090/calendar" ``` ### Notes Application ```bash # 返回笔记列表 # GET /notes/ # [{ "id": 0, "description": "Hello, this is a note." }] curl "http://localhost:8080/notes" # 新增笔记 # POST /notes # { "id": 1, "description": "ImANote" } curl -X POST "http://localhost:8080/notes?desc=ImANote" # 新增笔记,但是从 Calendar 服务获取时间 # { "id": 2, "description": "HiImANoteWithDate. Message Date: 09/21/2022" } curl -X POST "http://localhost:8080/notes?desc=ImANoteWithDate&add_date=y" # 根据 ID 返回笔记 # GET /notes/:id # { "id": 1, "description": "ImANote" } curl 'http://localhost:8080/notes/1' # 更新笔记 # PUT /notes/:id # { "id": 1, "description": "UpdatedNote" } curl -X PUT 'http://localhost:8080/notes/1?desc=UpdatedNote' # 删除笔记 # DELETE /notes/:id # { "message": "note with id 4 deleted." } curl -X DELETE 'http://localhost:8080/notes/1' ```