2014-09-29 78 views
8

我试图在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个不同的文件夹,其中有类文件> 我每次更改项目键,因为我读它必须是唯一的。

+0

你在http://stackoverflow.com/questions/21204350/sonar-setup-undefined-mandatory-properties看到答案吗?它看起来像你有同样的问题。 – 2014-09-29 05:13:57

+0

尼克,是的,我也修改了属性文件。仍然没有工作 – baconSoda 2014-09-29 05:18:31

+0

@ Karthikeyan,感谢您的编辑。我是堆栈溢出新手 – baconSoda 2014-09-29 05:23:03

回答

7

如何上传项目到SonarQube:

1)启动SonarQube。如果您在浏览器中键入localhost:9000,您应该能够看到它。

2)在命令提示符下,cd到你的项目 enter image description here

3)确保你的项目的根文件夹中有“sonar-project.properties”文件的目录中,并且配置。如果你的项目没有“sonar-project.properties”文件,它会得到这个错误= Sonar Setup Undefined Mandatory Properties

我“sonar-project.properties”文件我VendingMachineEmulator的应用程序是这样的: enter image description here

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并检查项目是否在那里。

+0

与上面几个声纳性能 'sonar.projectKey = MyWebApp sonar.projectBaseDir =。/ MyWebApp sonar.projectName = MyWebApp sonar.projectVersion = 1.0 sonar.sources =沿回答。/ SRC /主/ JAVA sonar.language = java sonar.java.binaries =。 sonar.scm.disabled = True sonar.sourceEncoding = UTF-8' – 2017-10-29 14:38:35

0

尝试从sonar-project.properties所在目录运行sonar-scanner命令。

我面临同样的问题,后来发现我从不同的目录运行命令。