安装

1. 从官网下载,https://www.sonarqube.org/downloads/

2. 下载之前要看好要求,我安装的是7.6的版本,要求是jdk1.8,mysql 5.6 到8 ,我使用的是5.7

3. 下载之后解压出来,运行bin 》 windows-x86-64 》 StartSonar.bat 不同操作系统不同。访问localhost:9000,能看到页面,就说明环境没问题。否则会提升jdk版本不对。

4. 在conf 》 sonar.properties中,加入如下配置,再执行3。记得删掉注释。如果启动后日志报错,可以清楚任务管理中所有的java进程,再启动。

如果启动成,在刚建的数据中,会有表生成。

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.username=用户名 // 刚刚创建的sonarQube用户
sonar.jdbc.password=密码 // 创建用户对应的密码
sonar.sorceEncoding=UTF-8 // 设置编码格式为UTF-8

5. 访问http://localhost:9000 默认账号密码都是admin

安装中文

下载地址:https://github.com/SonarQubeCommunity/sonar-l10n-zh

1. extensions 》 plugins

如下所示,点击下载,之后等待安装完成后重启。

安装sonar-scanner

下载地址:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/

解压出来,将bin目录加到path中,在cmd中,执行sonar-scanner -v,有日志输出即可。

使用方式一

在sonar的页面上,建立项目,我这里用的java ,用maven 构建的

使用方式二

使用sonar-scanner来扫描

1. 在项目下新建文件sonar-project.properties

# must be unique in a given SonarQube instance
sonar.projectKey=demo1
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=demo1
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8 sonar.login=39aff716f3014a7d341f6eae2ac4aec8887b9ce7
sonar.sources=src # sonar.projectKey=项目的key(自定义)
# sonar.projectName=项目名称
# sonar.projectVersion=项目版本
# sonar.sources=项目路径
#添加下面这行
sonar.java.binaries=./target/classes #只检查java文件
sonar.inclusions=src/main/java/com/demo/**/*.java

2. 运行 sonar-scanner.bat -Dsonar.login=39aff716f3014a7d341f6eae2ac4aec8887b9ce7 -Dsonar.java.binaries=./target/classes ,到项目目录下执行。

执行完,会生成检测报告

个人感觉第二种方便些。

参考资料:

sonar配置:https://blog.csdn.net/weixin_40861707/article/details/82117232

scan配置:https://my.oschina.net/guiguketang/blog/1814985

sonar安装和使用的更多相关文章

  1. Sonar安装与使用说明

    我总结的Sonar安装与使用说明,需要的可以去网盘下载. 网盘地址: http://pan.baidu.com/s/199BII

  2. findbug、p3c、checkstyle、sonar安装使用

    idea插件安装方式: Preferences—>Plugins—>查找插件—>Install Preferences—>Plugins—>Install plug fr ...

  3. sonar安装

    ##jdk不要用yum下载的 一.下载sonar源码 cd /usr/local/src wget https://sonarsource.bintray.com/Distribution/sonar ...

  4. Java代码质量监控工具Sonar安装

    1.  代码质量七宗罪 Sonar是一个代码质量管理系统.它的帮助文档开篇明义,提出了代码质量的七宗罪.总结的比較到位.最好还是一看: 1.        Bug和隐藏Bug(Bugs and Pot ...

  5. 高版本sonar安装遇到的坑-sonar 6.6

    最近安装了6.6版本的sonar,发现里面的坑还是很多,下面列举下遇到的坑 sonar插件地址:https://docs.sonarqube.org/display/PLUG/Plugin+Libra ...

  6. jenkins + sonar 安装配置

    最近把snoar 添加上了 [root@snoar data]#   wget https://sonarsource.bintray.com/Distribution/sonarqube/sonar ...

  7. 高版本sonar安装遇到的坑-sonar 6.7.5

    最近安装了6.7.5版本的sonar,发现里面的坑还是很多,下面列举下遇到的坑 sonar插件地址:https://docs.sonarqube.org/display/PLUG/Plugin+Lib ...

  8. Sonar安装-Linux[20171227]

    前言     一款不错的代码质量管理工具Sonar 前期准备     官方参考文档 https://docs.sonarqube.org/display/SONAR/Documentation     ...

  9. 代码检查工具 Sonar 安装&使用

    本文主要说明Sonar的安装方式并附上依赖安装包,本文目标只实现本地搭建测试的Sonar环境,以及本地的测试项目的非定制化扫描 本机测试环境:Win10-X64,.vs2017      依赖包: 1 ...

随机推荐

  1. 设计模式之工厂模式(Factory)

    转载请标明出处:http://blog.csdn.net/shensky711/article/details/53348412 本文出自: [HansChen的博客] 设计模式系列文章: 设计模式之 ...

  2. 【Android - 控件】之MD - CardView的使用

    CardView是Android 5.0新特性——Material Design中的一个布局控件,可以通过属性设置显示一个圆角的类似卡片的视图. 1.CardView的属性: app:cardCorn ...

  3. jQuery上拉加载更多

    <header id="header">首 页</header> <section id="main"> <ul id ...

  4. centos使用yum存储快速安装MySQL

    RHEL/CentOS 7.x MySQL yum库 https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm RHEL ...

  5. luogu P1168 中位数 |树状数组+二分

    题目描述 给出一个长度为NN的非负整数序列A_i,对于所有1 ≤ k ≤ (N + 1) / 21≤k≤(N+1)/2,输出A_1, A_3, -, A_2k - 1的中位数.即前1,3,5,-个数的 ...

  6. 牛客竞赛-Who killed Cock Robin

    Who killed Cock Robin? I, said the Sparrow, With my bow and arrow,I killed Cock Robin. Who saw him d ...

  7. SmartSVN提示 svn: File has inconsistent newlines 解决

    用SmartSVN提交代码的时候提示:svn: File has inconsistent newlines 本文转自:http://www.youduoshao.com/2014-10-05/201 ...

  8. Codeforce-620C

    There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the rig ...

  9. 1、在aspx.cs后台Response.Write()跳转路径,打开新窗口

    1.Response.Write()打开新窗口 Response.Write(" <script type='text/JavaScript'>window.open('&quo ...

  10. ARTS-S 最难的事情

    小朋友不舒服,看了医生也开了药吃了.但还是一直闹,不睡觉,弄的我和我爱人精疲力尽. 现在看来,技术上的难题真不算什么.照顾小朋友才是这个世界上最难的事情.