当前位置: 首页 > news >正文

果洛wap网站建设哪家好东莞网站seo技术

果洛wap网站建设哪家好,东莞网站seo技术,全网视频合集网站建设,网站首页内容文章目录 环境说明以及准备一. SonarQube的下载与安装二. 添加SonarQube项目三. 使用Maven命令上传代码到SonarQube四. IDEA安装SonarLint插件 环境说明以及准备 本篇博客使用的SonarQube版本为9.8,注意JDK 1.8已经不能支持 NameVersionDownLoad LinkSonarQube9.8…

文章目录

    • 环境说明以及准备
    • 一. SonarQube的下载与安装
    • 二. 添加SonarQube项目
    • 三. 使用Maven命令上传代码到SonarQube
    • 四. IDEA安装SonarLint插件


环境说明以及准备

本篇博客使用的SonarQube版本为9.8,注意JDK 1.8已经不能支持

NameVersionDownLoad Link
SonarQube9.8https://www.sonarsource.com/products/sonarqube/downloads/historical-downloads/
JDK11https://pan.quark.cn/s/06848544167c
PostgreSQL14.2https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

更多环境配置请参考:https://docs.sonarsource.com/sonarqube/9.8/requirements/prerequisites-and-overview/

在这里插入图片描述

一. SonarQube的下载与安装

1.下载9.8版本压缩包:
在这里插入图片描述
2.解压缩后找到/conf文件夹下的sonar.properties文件

在这里插入图片描述
3.增加postgresql连接配置

sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube
sonar.jdbc.username=postgres
sonar.jdbc.password=postgres

在这里插入图片描述
postgresql配置:

在这里插入图片描述

4.找到\bin\windows-x86-64文件夹下的StartSonar.bat文件,双击启动

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

5.启动成功后,访问http://localhost:9000/
初始用户名和密码 admin -> admin

在这里插入图片描述6.修改初始密码

在这里插入图片描述

7.修改完密码之后你就能成功看到SonarQube的页面

在这里插入图片描述

二. 添加SonarQube项目

SonarQube可以从你的远程Git仓库中读取代码并扫描。
本篇博客主要说明如何在本地通过手动添加并上传到SonarQube进行代码审查

1.点击Manually,创建一个新的project

在这里插入图片描述
2.注意这里的Project Key是你代码pom.xml文件中的artifactId
我这里随便找了个demo项目作为示例:

在这里插入图片描述

在这里插入图片描述
3.生成token,token名称你可以自己定,我们使用maven命令上传到SonarQube的时候需要带上这个token
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

三. 使用Maven命令上传代码到SonarQube

1.修改Maven的setting.xml文件,增加sonarqube配置,具体可以参考 SonarQube maven配置

在这里插入图片描述
2.setting.xml配置代码

  <pluginGroups><!-- sonarqube --><pluginGroup>org.sonarsource.scanner.maven</pluginGroup></pluginGroups>
	<profiles><profile><id>sonar</id><activation><activeByDefault>true</activeByDefault></activation><properties><!-- Optional URL to server. Default value is http://localhost:9000 --><sonar.host.url>http://localhost:9000</sonar.host.url></properties></profile></profiles>

在这里插入图片描述
在这里插入图片描述
3.提交代码中需要在pom.xml文件中添加jacoco-maven-plugin插件来帮助你生成test的覆盖率report

        <dependency><groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><version>0.8.1</version><type>pom</type></dependency>
            <plugin><groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><version>0.8.8</version><executions><execution><goals><goal>prepare-agent</goal></goals></execution><execution><id>report</id><phase>test</phase><goals><goal>report</goal></goals></execution></executions></plugin>

4…然后在你代码目录下(pom.xml文件同级目录),运行以下命令即可:
将上述SonarQube提示的maven命令简化成一行命令:

mvn clean verify sonar:sonar \-Dsonar.projectKey=redis-demo \-Dsonar.host.url=http://localhost:9000 \-Dsonar.login=sqp_70f1378aff945b99a854006d4b532f0081cc49f2

注意这里Dsonar.login的值就是上面拿到的token

mvn clean verify sonar:sonar -Dsonar.projectKey=redis-demo -Dsonar.host.url=http://localhost:9000 -Dsonar.login=sqp_70f1378aff945b99a854006d4b532f0081cc49f2

5.运行成功后,你就能在SonarQube上面看见一些report

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
6.如果你有一些代码不想让SonarQube扫描,你还可以添加以下配置

        <sonar.exclusions><!-- 指定需要排除的包 -->src/main/java/com/example/redisdemo/config/**,<!-- 排除以Config结尾的类 -->src/main/java/com/example/redisdemo/config/*Config.*</sonar.exclusions><sonar.coverage.exclusions>**/generated/**</sonar.coverage.exclusions>

在这里插入图片描述

四. IDEA安装SonarLint插件

1.在Settings中的Plugins查找SonarLint插件并安装

在这里插入图片描述
2.安装完成后重启IDEA,选中需要检查的文件右键SonarLint-> Analyze with SonarLint

在这里插入图片描述
3.在下面的控制台左侧就是扫出来全部有问题的代码,双击每个错误代码块,右侧会出现修改提示。在真实项目开发的背景下,我们在本地安装SonarLint插件能够及时发现一些代码问题,减少后续代码的维护时间。一般来说红色Critical的issue是一定需要解决的,其他级别的issue需要看项目定的issue处理级别。

在这里插入图片描述

http://www.dt0577.cn/news/14906.html

相关文章:

  • 网络公司做网站价格网络营销的优势包括
  • 南京科技网站设计费用百度怎么进入官方网站
  • 四川高端网站建设微信小程序怎么开通
  • 新闻网站审批web网页制作教程
  • 做外贸比较好的网站谷歌seo
  • 网站开发 手机 验证码网站推广的常用方法
  • 哈尔滨网站建设市场分析知乎seo排名帝搜软件
  • 乌鲁木齐网站设计服务商百度推广优化排名
  • 做外贸站推广如何网络营销
  • 郑州小程序seo外包公司怎么样
  • 做网站 空间河南百度关键词优化排名软件
  • 做网站给不给源代码企业邮箱网页版
  • 汇算清缴在哪个网站做网站新站整站排名
  • 七牛wordpress后台慢深圳seo优化外包
  • 怎么可以找到做公益的网站惠州大亚湾经济技术开发区
  • 网站建设 html排名app
  • 怎么做一个网站多少钱教育机构排名
  • 做微信充值网站百度关键词排名突然消失了
  • sina邮箱登录入口链接优化方法
  • 做网站用地图seo优化流程
  • 网站开发整合编辑器竞价托管代运营多少钱
  • 门户网站案例手游推广平台代理
  • 广州越秀建网站竞价开户
  • 用java做中小企业网站多百度客户端官网
  • 优秀网站参考seo是干嘛的
  • 北京高端网站建设咸阳互联网广告投放
  • 济南有哪些网站是做家具团购的长春seo主管
  • 服装公司网站策划书推广引流图片
  • linux下用python做网站百度指数查询排行榜
  • 闵行网站建站多少钿余姚seo智能优化