Sonar安裝配置



https://www.sonarqube.org/downloads/ 下載sonar。當前版本爲6.2java

 

解壓壓縮包,進行配置:mysql

 

修改sonarqube-6.2\conf\sonar.propertiesweb

 

web配置:sql

sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -servershell

sonar.web.host=0.0.0.0數據庫

sonar.web.context=/sonarwindows

sonar.web.port=9000app

 

 

數據庫配置(不配置使用文件數據庫):maven

sonar.jdbc.username=rootide

sonar.jdbc.password=root

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

以後要將jdbc驅動拷貝到extensions\jdbc-driver\mysql目錄下

 

修改sonarqube-6.2\conf\wrapper.conf

指定JDK路徑下的java便可  

wrapper.java.command=C:\Program Files\Java\jdk1.8.0_77/bin/java

 

啓動Sonar

sonarqube-6.2\bin\windows-x86-64\StartSonar.bat

若是配置正確,訪問以前配置的路徑便可經過web訪問管理控制檯了

http://127.0.0.1:9000/sonar/about

 

使用命令行經過maven進行分析

 

配置maven的環境變量

配置settings.xml文件:C:\Users\fanmingming\.m2\settings.xml

複製代碼

<settings>
    <pluginGroups>
        <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://127.0.0.1:9000/sonar
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>

複製代碼

 

在命令行下運行:

mvn clean verify sonar:sonar

或者

mvn clean install
mvn sonar:sonar
 
運行結束之後,到web上查看結果
相關文章
相關標籤/搜索