简体   繁体   English

我应该如何编辑我的 pom.xml 文件以将我的 maven 项目导入到 sonarqube?

[英]How should I edit my pom.xml file to import my maven project to sonarqube?

I am using JDK 1.8 and Maven using Eclipse IDE. I want to analyze my project on SonarQube 6.6.我正在使用 JDK 1.8 和 Maven 使用 Eclipse IDE。我想在 SonarQube 6.6 上分析我的项目。 Here is my pom.xml file:这是我的 pom.xml 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>ADDITION</groupId>
  <artifactId>Addition</artifactId>
  <version>0.0.1-SNAPSHOT</version>

<dependencies>

<dependency>
  <groupId>junit</groupId>     <!-- NOT org.junit here -->
  <artifactId>junit-dep</artifactId>
  <version>4.8.2</version>
  <scope>test</scope>
</dependency>
<!-- 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.1.1</version>
</dependency>



</dependencies>

<build>
<plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.10.1</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
  
</plugins>
</build>
</project>

And this is the output with error: (localhost:9000 is the default port for SonarQube and it is working fine. But the problem is I cannot import my maven project to sonar. If anyone finds the solution, please help. Thank you.)这是 output,有错误:(localhost:9000 是 SonarQube 的默认端口,它工作正常。但问题是我无法将我的 maven 项目导入声纳。如果有人找到解决方案,请帮忙。谢谢。)

    C:\eclipse-workspace\Addition>mvn sonar:sonar
[INFO] Scanning for projects...
[WARNING] The artifact org.codehaus.mojo:sonar-maven-plugin:jar:3.9.1.2184 has been relocated to org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.9.1.2184: SonarQube plugin was moved to SonarSource organisation
[INFO]
[INFO] -----------------< ADDITION:Addition >-----------------
[INFO] Building Addition 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.9.1.2184:sonar (default-cli) @ Addition ---
[INFO] User cache: C:\Users\arghy\.sonar\cache
[ERROR] SonarQube server [http://localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.057 s
[INFO] Finished at: 2022-04-01T13:58:31+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project Addition: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000: Connection refused: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Looks like localhost resolves to the ipv6 adress, maybe sonarqube doesn't support that.看起来本地主机解析为 ipv6 地址,也许 sonarqube 不支持。 What happens if you change http://localhost:9000 to http://127.0.0.1:9000 ?如果将http://localhost:9000更改为http://127.0.0.1:9000会怎样?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我第一次创建一个 Maven 项目时,它在我的 pom.xml 文件中显示错误,错误是: - when i created a maven project for the first time it shows me error in my pom.xml file the error is : 在maven pom.xml中,如何指定我要将“ .xml”文件复制到目标文件夹中? - In maven pom.xml, how to specify that I want to copy a “.xml” file into my target folder? 在 eclipse 中导入 maven 项目时缺少 pom.xml 文件 - pom.xml file is missing when import maven project in eclipse 在具有多个 POM.xml 文件的嵌套项目中,如何知道哪个 pom 属于 Intellij 中的当前模块? - How can I know which pom belongs my current module in Intellij in a nested project with multiple POM.xml file? 为什么我无法在Maven存储库中的Android项目中使用库? 如何为此编写正确的pom.xml? - Why I can't use a library in my Android project from Maven repository? How to write a correct pom.xml for this? 尽管pom.xml文件中存在特定导入,但我的项目看不到该特定导入 - my project does not see the a specific import despite its presence in pom.xml file 我的pom.xml出现Maven错误 - maven error with my pom.xml 我的项目的pom.xml错误 - My project's pom.xml error 如何最小化Maven POM.XML文件 - How can I minimize Maven POM.XML file 如何参数化Maven文件(pom.xml)? - How to parameterize a Maven file (pom.xml)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM