# java-agent **Repository Path**: caiyanghui/java-agent ## Basic Information - **Project Name**: java-agent - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-08-12 - **Last Updated**: 2025-08-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # java-agent ## simple-agent ``` 1、编译agent代码 javac -encoding UTF-8 com/example/agent/SimpleAgent.java // 如果不加-encoding UTF-8可能会报如下错误 src\org\example\MyAgent.java:18: 错误: 编码 GBK 的不可映射字符 (0xB0) // 鎵撳嵃姝e湪鍔犺浇鐨勭被鐨勫悕绉? ^ 1 个错误 2、编写MANIFEST.MF文件 3、使用jar命令将编译后的类和MANIFEST.MF文件打包成JAR文件 jar cmf MANIFEST.MF SimpleAgent.jar com/example/agent 4、运行带有Agent的Java程序 javac com/example/app/SimpleApp.java java -javaagent:SimpleAgent.jar=includes=* -cp . com/example/app/SimpleApp ``` 添加agent: -javaagent:D:\MyProjects\java-agent\bytebuddy-agent\target\bytebuddy-agent-1.0-SNAPSHOT-jar-with-dependencies.jar 带参数: -javaagent:/path/to/agent.jar=dbUrl=jdbc:mysql://localhost:3306/test,username=root,password=123456 http://127.0.0.1:8080/web-app/hello?sid=123456 http://127.0.0.1:8080/web-app/api/hello?name=张三 http://127.0.0.1:8080/web-app/api/users/1 http://127.0.0.1:8080/web-app/api/users http://127.0.0.1:8080/web-app/api/users/json http://127.0.0.1:8080/web-app/api/upload http://127.0.0.1:8080/web-app/api/download/1.txt http://127.0.0.1:8080/web-app/api/users/123 http://127.0.0.1:8080/web-app/api/users/123 http://127.0.0.1:8080/web-app/api/data http://127.0.0.1:8080/web-app/api/v1/departmentOption?deptCode=1001&deptCodeList=1002,1003&deptTypeEnum=DISCHARGE_DEPT&excludeNullDrgFlag=true export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/fs_conf/buddy-agent/fire-buddy-agent-1.0.0-jar-with-dependencies.jar" export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/fs_conf/buddy-agent/controller-agent-1.0.jar"