# Using SonarQube with Maven

In 
Published 2022-12-03

This tutorial explains to you how to use SonarQube with Maven.

For using SonarQube with Maven we need to:

  • add in pom.xml the SonarQube Scanner For Maven dependency from mvn repository

In my case, I used:

       <!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
		<dependency>
			<groupId>org.sonarsource.scanner.maven</groupId>
			<artifactId>sonar-maven-plugin</artifactId>
			<version>3.9.1.2184</version>
		</dependency>
  • add some JUnit test to your code.

You can take a look at Junit5 Example (with Maven).

  • create a SonarQube project

For this step you can take a look at the tutorial named Create a new Project.

  • go to Spring Boot project and run the following command:
mvn clean verify sonar:sonar -Dsonar.projectKey=MyProject-1 -Dsonar.host.url=http://127.0.0.1:9000 -Dsonar.login=sqp_fbc278b701f40bc801e95056e1ed602ccb99d698

When this command completes, you can see the result in SonarQube:

In this picture you cannot see all the information SonarQube have collected, but I encourage you to test it and see live all the information SonarQube generates.