简体   繁体   English

SonarQube - mvn 声纳:声纳 - NoSuchElementException

[英]SonarQube - mvn sonar : sonar - NoSuchElementException

I have a project on SonarQube but when I try to update it with the follow command in the terminal it gets me the this error:我在 SonarQube 上有一个项目,但是当我尝试在终端中使用以下命令更新它时,出现了这个错误:

[ERROR] NoSuchElementException [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] NoSuchElementException [ERROR] [ERROR] 要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。 [ERROR] Re-run Maven using the -X switch to enable full debug logging. [错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。

I have searched online but apparently nobody knows the answer, so I thought I'd give it a try.我在网上搜索过,但显然没有人知道答案,所以我想我会试一试。

I have the following project structure:我有以下项目结构:

  • Project name项目名
    • Dal木豆
    • SharedModel共享模型
    • WebsocketClient Websocket客户端
    • WebsocketServer Websocket服务器

So in total I have 4 modules.所以我总共有 4 个模块。 My main pom.xml looks like this:我的主要 pom.xml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.8.RELEASE</version>
  </parent>
  <groupId>myproject.nl</groupId>
  <artifactId>myproject</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <modules>
    <module>websocketserver</module>
    <module>websocketsclient</module>
    <module>sharedmodel</module>
    <module>Dal</module>
  </modules>
  <name>PartieKo</name>


  <dependencies>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>
    <!-- JUnit 5 -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.5.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>11</source>
          <target>11</target>
        </configuration>

      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M3</version>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

Your command is wrong:你的命令是错误的:

mvn sonar : sonar   // WRONG

Remove the spacers between sonar and sonar and add the Sonar server address:去掉sonar和sonar之间的间隔符,添加Sonar服务器地址:

mvn sonar:sonar -Dsonar.host.url=https://mysonarserver:9000

The sonar server configuration can also be configured in the pom.xml file (add in the properties section) sonar server配置也可以在pom.xml文件中配置(在properties部分添加)

<properties>
    ...
    <sonar.host.url>https://mysonarserver:9000</sonar.host.url>
</properties>

Command mvn sonar scanner on windows在 windows 上命令 mvn sonar scanner

mvn sonar:sonar `
  "-Dsonar.projectKey=xxxxx" `
  "-Dsonar.host.url=http://local:9000" `
  "-Dsonar.login=xxxxxxxxx"

Linux After adding project on sonar console manualy,sonar will give you the next command. Linux 在声纳控制台手动添加项目后,声纳会给你下一个命令。

mvn sonar:sonar \
  "-Dsonar.projectKey=xxxxx" \
  "-Dsonar.host.url=http://localhost:9000" \
  "-Dsonar.login=xxxxxxxxx"

You can also put url/host/login in pom file or env config.您还可以将 url/host/login 放在 pom 文件或 env 配置中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM