sonar客户端Sonar Runner配置

1.下载Sonar Runner

http://www.sonarqube.org/downloads/

 

2.解压到对应目录,如我的是D:\Program Files

 

3.配置环境变量

 

SONAR_RUNNER_HOME = D:\Program Files\sonar-runner-2.3

 

在Path下添%SONAR_RUNNER_HOME%/bin

 

4.修改配置文件conf/sonar-runner.properties文件

#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here

#----- Default SonarQube server
sonar.host.url=http://127.0.0.1:9000/sonar

#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar

#----- MySQL
sonar.jdbc.url=jdbc:mysql://127.0.0.1:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driver=com.mysql.jdbc.Driver

#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE

#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor

#----- Global database settings
sonar.jdbc.username=root
sonar.jdbc.password=root

#----- Default source code encoding
#sonar.sourceEncoding=UTF-8

#----- Security (when 'sonar.forceAuthentication' is set to 'true')
sonar.login=admin
sonar.password=admin

 sonar服务器地址 

  sonar服务器的数据库地址 数据库用户名密码

  sonar服务器的用户名密码

 

5.项目中运用

 

在项目源文件目录下新建一个文件名为sonar-project.properties的文件,在文件中输入以下内容:

# required metadata

# My project------修改成你的项目名称

sonar.projectKey=test

sonar.projectName=test

sonar.projectVersion=1.0

 

# path to source directories (required)

# srcDir1,srcDir2---------修改成你的源文件夹路径

sources=src

 

# path to test source directories (optional)

# testDir1,testDir2--------修改成你的测试文件夹路径

#tests=testDir1,testDir2

 

# path to project binaries (optional), for example directory of Java #bytecode

# binDir--------修改成你的二进制文件夹路径

#binaries=

 

# path to project libraries (optional)

#libraries=junit.jar

 

# advanced parameters

#my.property=value

 

然后在命令行下进入项目的目录,输入sonar-runner

 

完成后可在sonar服务器上看到运行结果

 

可能出错如下:

 

ERROR: Caused by: The current batch process and the configured remote server do

 

not share the same DB configuration.

 

查看sonar服务器

http://127.0.0.1:9000/sonar/api/server (如果sonar服务器的sonar.web.context是/,则是http://192.168.20.246:9000/api/server)

 

 

select * from properties where prop_key = 'sonar.core.id'

如果两者不同,将数据库的改成和服务器上的一样即可。

 

为什么不同暂时没研究出来。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值