代码之家  ›  专栏  ›  技术社区  ›  Arghya Saha

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

  •  0
  • Arghya Saha  · 技术社区  · 3 年前

    我使用的是JDK1.8,Maven使用的是EclipseIDE。我想分析我在SonarQube 6.6上的项目。这是我的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>
    

    这是有错误的输出: (localhost:9000是SonarQube的默认端口,工作正常。但问题是我无法将我的maven项目导入sonar。如果有人找到解决方案,请提供帮助。)。 谢谢。)

        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
    
    0 回复  |  直到 3 年前
        1
  •  0
  •   Johan Nordlinder    3 年前

    看起来localhost解析为ipv6地址,可能sonarqube不支持。如果你改变了怎么办 http://localhost:9000 http://127.0.0.1:9000 ?