教你快速搭建sona服务及idea使用sona的方法
作者:前路无畏 时间:2023-11-20 05:22:53
目录
Sonar概述
一、 搭建sona服务
二、idea配置
三、 配置maven的setting.xml文件
四、idea中 mvn sonar:sonar 执行命令
五 访问sona查看问题
六、汉化
Sonar概述
Sonar 是一个用于代码质量管理的开放平台。通过插件机制,Sonar 可以集成不同的测试工具,代码分析工具,以及持续集成工具。与持续集成工具(例如 Hudson/Jenkins 等)不同,Sonar 并不是简单地把不同的代码检查工具结果(例如 FindBugs,PMD 等)直接显示在 Web 页面上,而是通过不同的插件对这些结果进行再加工处理,通过量化的方式度量代码质量的变化,从而可以方便地对不同规模和种类的工程进行代码质量管理。
在对其他工具的支持方面,Sonar 不仅提供了对 IDE 的支持,可以在 Eclipse 和 IntelliJ IDEA 这些工具里联机查看结果;同时 Sonar 还对大量的持续集成工具提供了接口支持,可以很方便地在持续集成中使用 Sonar。
此外,Sonar 的插件还可以对 Java 以外的其他编程语言提供支持,对国际化以及报告文档化也有良好的支持。
一、 搭建sona服务
1.下载pg数据库:
docker pull postgres
2. 下载sonaqube,版本锁定在7.9.1-community
docker pull sonarqube:7.9.1-community
3. 启动pg数据库
docker run --name postgresqldb -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -d postgres
说明:
postgresqldb :数据库名字
sonar : 用户名
sonar : 密码
4. 启动sona
docker run --name sq --link postgresqldb -e SONARQUBE_JDBC_URL=jdbc:postgresql://postgresqldb:5432/sonar -p 9999:9000 -d sonarqube:7.9.1-community
说明:
sq : sona名字
postgresqldb :pg数据库的容器名字
jdbc:postgresql://postgresqldb:5432/sonar :pg数据库的连接;sonar 为数据库名字
9999:9000 : 9999为对外暴露的端口,因为9000我的其他服务已将捷足先登,被占用了,我这里使用9999; 9000: sona容器内部的提供服务的端口
sonarqube:7.9.1-community 镜像名字
使用portainer显示正常,后者使用其他方法,确认正常,
浏览器输入连接也可以确认正常:http://10.1.8.151:9999/
用户名:admin 密码: admin
二、idea配置
三、 配置maven的setting.xml文件
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- 配置 Sonar Host地址,默认:http://localhost:9000 -->
<sonar.host.url>
http://10.1.8.151:9999/
</sonar.host.url>
</properties>
</profile>
四、idea中 mvn sonar:sonar 执行命令
大约过去2分钟。执行完成。
五 访问sona查看问题
六、汉化
来源:https://blog.csdn.net/fsjwin/article/details/118152826
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解java 中Spring jsonp 跨域请求的实例
![](https://img.aspxhome.com/file/2023/7/59667_0s.png)
Java中的this和super实例浅析
C#中事件处理的个人体会
DataGridView控件显示行号的正确代码及分析
IDEA中创建maven项目引入相关依赖无法下载jar问题及解决方案
![](https://img.aspxhome.com/file/2023/5/88505_0s.png)
Java Swing实现简单的体重指数(BMI)计算器功能示例
![](https://img.aspxhome.com/file/2023/6/65756_0s.gif)
Android Studio 4.1没有GsonFormat插件的解决
![](https://img.aspxhome.com/file/2023/9/137799_0s.jpg)
java寻找迷宫路径的简单实现示例
Java后端学习精华之TCP通信传输协议详解
![](https://img.aspxhome.com/file/2023/1/64221_0s.png)
JavaWeb中JavaMail创建邮件和发送邮件
![](https://img.aspxhome.com/file/2023/8/110918_0s.png)
Java日常练习题,每天进步一点点(17)
![](https://img.aspxhome.com/file/2023/0/132200_0s.png)
Android应用中使用SharedPreferences类存储数据的方法
![](https://img.aspxhome.com/file/2023/8/96768_0s.gif)
Java web的读取Excel简单实例代码
![](https://img.aspxhome.com/file/2023/6/78946_0s.png)
C#对象为Null模式(Null Object Pattern)实例教程
![](https://img.aspxhome.com/file/2023/8/89788_0s.png)
C#执行EXE文件与输出消息的提取操作
![](https://img.aspxhome.com/file/2023/7/85717_0s.jpg)
Spring Boot Actuator自定义健康检查教程
Spring定时任务使用及如何使用邮件监控服务器
android LabelView实现标签云效果
![](https://img.aspxhome.com/file/2023/5/138285_0s.gif)
Android实现房贷计算器
![](https://img.aspxhome.com/file/2023/8/125388_0s.jpg)