Sonar static code scanning environment Construction (WINDOWS10)

Source: Internet
Author: User

First, the Environment configuration: 1, JDK Installation and configuration 2, MySQL database installation----directly call the server yard MySQL database, on this basis to create a new database sonar. The database configuration is as follows: 3, the sonar official website downloads the sonarqube version, chooses 5.6.3 version, the official website says is the long-term support, therefore chooses this version. Note that the Sonarqube corresponding sonar scanner version number is 2.8. can also use Sonar runner, in fact runner and scanner like. http://www.sonarqube.org/downloads/Download the sonarqube5.6.3 version and unzip to the corresponding directory, configure the environment variables:
    • sonar_home:d:\sonar\sonarqube-5.6.3\sonarqube-5.6.3
    • Path:%sonar_home%\bin
    • To configure the Conf/sonar.properties file:
    • Sonar.jdbc.username=sonar
      Sonar.jdbc.password=sonar
      sonar.jdbc.url=jdbc:mysql://172.168.1.4:3306/sonar?useunicode=true&characterencoding=utf8& Rewritebatchedstatements=true&useconfigs=maxperformance

4. After downloading the version of Sonar scanner2.8, unzip to the corresponding directory and configure the environment variables:

    • sonar_scanner_home:d:\sonar\sonar-scanner-2.8\sonar-scanner-2.8
    • Path:%sonar_scanner_home%\bin
    • To configure the Conf/sonar-scanner.properties file:

#-----Default SonarQube Server
Sonar.host.url=http://localhost:9000/

#-----Default Source Code encoding
Sonar.sourceencoding=utf-8

#-----Global Database Settings (not used for SonarQube 5.2+)
Sonar.jdbc.username=sonar
Sonar.jdbc.password=sonar

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

#-----MySQL
Sonar.jdbc.url=jdbc:mysql://172.168.1.4:3306/sonar?useunicode=true&characterencoding=utf8

5. Double-click D:\sonar\sonarqube-5.6.3\sonarqube-5.6.3\bin\windows-x86-64\StartSonar.bat to start the service, the following description service started successfully:

At this point, login http://localhost:9000/, the interface is as follows:

6, the default entry http://localhost:9000/display is in English, need to install Chinese plug-in package. Download the path to the Chinese plugin:

Administration--system-update center-available--Find Chinese pack installation.

Second, the project practice:

1, the project root directory to create sonar-project.properties, configured as follows:

The parameters are specific to your own project, language settings.

2, cmd switch to the project root directory, input Sonar-scanner run can:

3, after the end of the run, to Http://localhost:9000/view the test results, according to the test results to find problems in the code, analysis and processing, to optimize the code.

4. Problems encountered in practice procedures:

      • Install the Chinese plug-in package consistent prompt installation pending, and finally restart the computer well, do not know why
      • Sonar.properties After you configure the Web server to start the service successfully, the login http://localhost:9000/will not be able to open the Web page, currently does not solve the problem, not to configure this, the service can also start OK, Code success is not affected by this scan. If you have the same problem, please answer it, appreciate it!

Sonar static code scanning environment Construction (WINDOWS10)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.