Sonar 与 Maven 配置

### Sonar 与 Maven 配置 ###

1.下载sonar 包,解压

   [下载地址](http://www.sonarqube.org/downloads)


2.修改sonar 配置文件,设置数据库链接

    修改 sonar.properties 文件
    
    1.数据库账号、密码
        # User credentials.
        # Permissions to create tables, indices and triggers must be granted to JDBC user.
        # The schema must be created first.
        sonar.jdbc.username=kaifa_user
        sonar.jdbc.password=123456    
    
    2. 数据库地址
        #----- MySQL 5.x
        # Only InnoDB storage engine is supported (not myISAM).
        # Only the bundled driver is supported.
        sonar.jdbc.url=jdbc:mysql://172.16.9.22:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
    
3.启动sonar

    进入:  /usr/local/sonarqube-5.1.1/bin/linux-x86-64

    执行: ./sonar.sh  start

4.修改maven 配置。

    方式一:修改项目pom.xml文件
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <properties>
                <!-- EXAMPLE FOR MYSQL -->
                <sonar.jdbc.url>jdbc:mysql://172.16.9.22:3306/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url>
                <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
                <sonar.jdbc.username>kaifa_user</sonar.jdbc.username>
                <sonar.jdbc.password>123456</sonar.jdbc.password>

                <!-- SERVER ON A REMOTE HOST -->
                <sonar.host.url>http://172.16.9.22:9000</sonar.host.url>
            </properties>
        </profile>    


    方式二:修改本地maven  setting.xml 文件
        <profile>
           <id>sonar</id>
           <activation>
              <activeByDefault>true</activeByDefault>
           </activation>
           <properties>
              <sonar.jdbc.url>jdbc:postgresql://localhost/sonar</sonar.jdbc.url>
              <sonar.jdbc.driver>org.postgresql.Driver</sonar.jdbc.driver>
              <sonar.jdbc.username>user</sonar.jdbc.username>
              <sonar.jdbc.password>password</sonar.jdbc.password>
              <!-- SERVER ON A REMOTE HOST -->
              <sonar.host.url>http://localhost:9000</sonar.host.url>
           </properties>
        </profile>



5.提交项目

    进入项目根路径,执行  mvn  sonar:sonar

    

转载于:https://my.oschina.net/zhenghao/blog/615425

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值