java后台开发调试

导读:本篇文章讲解 java后台开发调试,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

java后台开发调试的几个常用工具

测试用到的代码:

springboot-druid

0.java编译可执行程序,manen打包

c:\jdk\demoapp> javac HelloWorld.java
c:\jdk\demoapp> java HelloWorld
命令行编译运行Java程序时,加载指定目录中的Jar包
编译:javac -Djava.ext.dirs=./lib Test.java 或 javac -Djava.ext.dirs=D:/javacode/lib
运行:java -Djava.ext.dirs=./lib Test

maven打包可以命令行也可以在编译器如idea中。

命令行:mvn -Dmaven.test.skip=true clean install

1.接口测试工具(curl;postman)

1)curl (curl -h 查询参数说明)

get请求:

curl http://192.168.3.2:8090/user?userName=admin\&passWord=1213
//带多个参数也可也:
curl  "http://192.168.3.2:8090/user?userName=admin&passWord=1213"
curl  -s "http://192.168.3.2:8090/user?userName=admin&passWord=1213"
//多个cookie使用分号分隔
curl http://localhost:8090/test --cookie "userName=root;passWord=123456"

//-u 带上代理用户信息,-i 参数来返回请求头和响应信息
curl -i -u guest:guest http://localhost:15672/api/vhosts

post:

1)普通参数

curl -X POST -d 'userName=admin23&passWord=123456' http://192.168.3.2:8090/user/add2

2)参数为json

curl  -H  "content-type:application/json"  -XPOST -d  '{"userName":"admin6","passWord":"123456"}' http://192.168.3.2:8090/user

put:

1)普通参数

curl -X PUT -d 'id=11&userName=admin23_update&passWord=123456' http://192.168.3.2:8090/user/update2

2)参数为json

curl  -H "content-type:application/json"  -XPUT -d'{"id":11,"userName":"admin23_update2","passWord":"123456"}'  http://192.168.3.2:8090/user

delete:

1)普通参数

curl -v -X DELETE http://192.168.3.2:8090/user?id=9

2)参数为json

 curl -i -u guest:guest -H "content-type:application/json"  -X DELETE -d'{"type":"direct","durable":true}' 
http://localhost:15672/api/exchanges/%2f/my-new-exchange2

2)postman使用和idea自带的Http client 工具类似:

get请求:
在这里插入图片描述

put:

在这里插入图片描述
在这里插入图片描述
post:

在这里插入图片描述
在这里插入图片描述
delete:
在这里插入图片描述

参考:https://www.cnblogs.com/duhuo/p/5695256.html

2.压力测试工具

1)ab使用

命令:

ab -n 100 -c 10 http://localhost:8090/user?userName=admin&passWord=123456
//需要登录的接口,登录后找到cookie
ab -n 100 -H “Cookie: Key1=Value1; Key2=Value2” http://localhost:8090/user?userName=admin&passWord=123456

输出:
在这里插入图片描述

2)apache-jmeter使用

1)点击jmeter.bat,打开界面
2)
在这里插入图片描述
3)
在这里插入图片描述
4)
在这里插入图片描述
6)
在这里插入图片描述
查看结果:
在这里插入图片描述

具体操作参考这篇:https://www.cnblogs.com/nancyzhu/p/8035042.html

3.内存,cpu等性能监控工具

1)jvisualvm 使用

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

其他使用可以参考:https://www.cnblogs.com/caroline4lc/p/4932937.html

2)Arthas使用

其他详细使用参考:https://alibaba.github.io/arthas/

启动进程:

nohup java -jar springboot-druid-0.0.1-SNAPSHOT.jar >>springboot-druid.out 2>&1 &

启动Arthas,然后选择应用java进程:需要输入[i]第几个进程,然后回车/enter

[root@localhost soft]# java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.1.0
[INFO] Found existing java process, please choose one and hit RETURN.
* [1]: 9779 -- process information unavailable
  [2]: 8756 -- process information unavailable
  [3]: 8844 -- process information unavailable
  [4]: 2511 springboot-druid-0.0.1-SNAPSHOT.jar
4
[INFO] arthas home: /root/.arthas/lib/3.1.0/arthas
[INFO] Try to attach process 2511
[INFO] Attach process 2511 success.
[INFO] arthas-client connect 127.0.0.1 3658

查看dashboard: dashboard

在这里插入图片描述

monitor方法执行监控:monitor -c 5 demo.MathGame primeFactors

monitor com.ctg.test.durid.controller.UserController.getUser

dump 已加载类的 bytecode 到特定目录:

dump com.ctg.test.durid.controller.UserController

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/18369.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!