簡體   English   中英

聲納:您必須為未解決的未知定義以下強制屬性

[英]Sonar: You must define the following mandatory properties for unknown not resolved

我正在嘗試在java中的項目上運行SonarQube。 我配置了聲納屬性文件並將其放在項目目錄中。 在運行sonar.bat時,會出現一個錯誤,要求定義必需參數。 起初我認為我的屬性文件是錯誤的,但我已經嘗試了我能想到的一切。

這是當前的屬性文件

# Required metadata
sonar.projectKey=_newtest2
sonar.projectName=NoSqlDataModeling
sonar.projectVersion=2.0

# Path to the parent source code directory.
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set. 
# If not set, SonarQube starts looking for source code from the directory containing 
# the sonar-project.properties file.
sonar.sources=D:/eclipse workspace/NoSqlDataModeling


#Comma-separated paths to directories containing the binary files (directories with class files, in the case of Java).
sonar.binaries=D:/eclipse workspace/NoSqlDataModeling/build/classes

#Comma-separated paths to files with third-party libraries (JAR files in the case of Java). Patterns #can be used.
sonar.libraries=D:/eclipse workspace/NoSqlDataModeling/WebContent/WEB-INF/lib/*.jar

#language used
sonar.language=java

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# Additional parameters
sonar.my.property=value

這是錯誤消息

INFO: SonarQube Server 4.3.1
09:58:57.783 INFO  - Load batch settings
09:58:57.901 INFO  - User cache: C:\Users\Rohan.Kumar\.sonar\cache
09:58:57.907 INFO  - Install plugins
09:58:57.913 INFO  - Download sonar-maven-batch-plugin-4.3.1.jar
09:58:58.037 INFO  - Download sonar-findbugs-plugin-2.1.jar
09:58:58.436 INFO  - Download sonar-surefire-plugin-2.1.jar
09:58:58.540 INFO  - Download sonar-cpd-plugin-4.3.1.jar
09:58:58.870 INFO  - Download sonar-core-plugin-4.3.1.jar
09:58:58.956 INFO  - Download sonar-java-plugin-2.1.jar
09:58:59.097 INFO  - Download sonar-dbcleaner-plugin-4.3.1.jar
09:58:59.216 INFO  - Download sonar-jacoco-plugin-2.1.jar
09:58:59.331 INFO  - Download sonar-l10n-en-plugin-4.3.1.jar
09:58:59.350 INFO  - Download sonar-squid-java-plugin-2.1.jar
09:58:59.453 INFO  - Download sonar-email-notifications-plugin-4.3.1.jar
09:58:59.655 INFO  - Download sonar-design-plugin-4.3.1.jar
09:58:59.826 INFO  - Install JDBC driver
09:59:00.061 WARN  - H2 database should be used for evaluation purpose only
09:59:00.061 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
09:59:00.784 INFO  - Initializing Hibernate
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 7.521s
Final Memory: 5M/19M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for 'Unknow
n': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with t
he -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

我應該為所有類文件和java文件提供逗號分隔的路徑嗎? 直到我提供的路徑是什么? 不同的類文件位於build / classes /.../.../ <4個不同的文件夾中,其中包含類文件>我每次都更改項目密鑰,因為我讀取它必須是唯一的。

如何將項目上傳到SonarQube:

1)啟動SonarQube。 如果在瀏覽器中鍵入localhost:9000,您應該能夠看到它。

2)在命令提示符下,cd到項目目錄 在此輸入圖像描述

3)確保項目的根文件夾具有“sonar-project.properties”文件並且已配置。 如果您的項目沒有“sonar-project.properties”文件,則會出現此錯誤= 聲納設置未定義的強制屬性

我的VendingMachineEmulator應用程序的“sonar-project.properties”文件如下所示: 在此輸入圖像描述

4)在命令提示符下,現在鍵入“C:\\ sonar-scanner \\ sonar-scanner-2.6.1 \\ bin \\ sonar-scanner.bat”。 或者,你也可以輸入“C:\\ sonar-scanner \\ sonar-scanner-2.6.1 \\ bin \\ sonar-runner.bat”。 我不確定區別是什么。 確保您所在的目錄仍然是項目的主文件夾。

5)完成! 刷新localhost:9000並檢查項目是否存在。

那些在項目文件夾中運行聲納 - 跑步者時“執行失敗”的人添加-Dproject.settings=./sonar-project.properties

由於無法找到設置文件,因此必須明確提及

sonar-project.properties是我項目中的文件名,我給了projectKey,projectName

對我來說, D:\\TB-2 24 sept\\server side\\ServerSide>C:\\Users\\m1042220\\Downloads\\sonar-plugin\\agent\\sonar-plugin-agent\\sonar-qube-runner\\bin\\sonar-runner -Dproject.settings=./sonar-project.properties

嘗試從sonar-project.properties所在的目錄運行sonar-scanner命令。

我遇到了同樣的問題,后來發現我從不同的目錄運行命令。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM