java SonarQube:“项目配置文件:无”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35314553/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SonarQube : " Project configuration file: NONE "
提问by user3568978
I've configured everything to do a Sonar analysis on a Maven project. Everything is fine until I run sonar-runner
:
我已经配置了所有内容来对 Maven 项目进行声纳分析。一切都很好,直到我运行sonar-runner
:
Max$ sonar-runner
INFO: Scanner configuration file: /Users/Max/Documents/sonar-scanner-2.5/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: SonarQube Scanner 2.5
INFO: Java 1.7.0_45 Oracle Corporation (64-bit)
INFO: Mac OS X 10.10.3 x86_64
INFO: User cache: /Users/Max/.sonar/cache
INFO: Load global repositories
INFO: Load global repositories (done) | time=143ms
INFO: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /Users/Max/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=4ms
INFO: Default locale: "fr_FR", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.631s
INFO: Final Memory: 40M/194M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to load component class org.sonar.batch.scan.ProjectLock
ERROR: Caused by: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
ERROR: Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Scanner with the -e switch.
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
- I'm running
sonar-runner
inside my java project folder I have put and configured the
sonar-runner.properties
?in my java projectsonar.projectKey=SeleniumMaven:sonar sonar.projectName=SeleniumMaven sonar.projectVersion=1.0 sonar.sources=src sonar.sourceEncoding=UTF-8 sonar.language=java
- 我
sonar-runner
在我的 java 项目文件夹中运行 我已经
sonar-runner.properties
在我的 java 项目中放置并配置了?sonar.projectKey=SeleniumMaven:sonar sonar.projectName=SeleniumMaven sonar.projectVersion=1.0 sonar.sources=src sonar.sourceEncoding=UTF-8 sonar.language=java
Any idea?
任何的想法?
回答by Hello_world
Try passing the values like this :
尝试传递这样的值:
sonar-runner -Dsonar.projectKey=..... -Dsonar.projectName=...
sonar-runner -Dsonar.projectKey=..... -Dsonar.projectName=...
if it works, it means the property file is somewhat ignored
如果它有效,这意味着属性文件有点被忽略
If you look at the following message :
如果您查看以下消息:
INFO: Scanner configuration file: /Users/Max/Documents/sonar-scanner-2.5/conf/sonar-runner.properties
INFO: Project configuration file: NONE
It seems like your project configuration file is indeed ignored
看来您的项目配置文件确实被忽略了
回答by Pratik
I had the same problem and I realized my file name was incorrect: instead of "sonar-project.properties" I had it as "sonar-project.properties.properties".
我遇到了同样的问题,我意识到我的文件名不正确:我把它作为“sonar-project.properties.properties”而不是“sonar-project.properties”。
I would try and change your file name to "sonar-project.properties" and try ...
我会尝试将您的文件名更改为“sonar-project.properties”并尝试...
回答by Максим Шатов
You need create a configuration filein the root directory of the project: sonar-project.properties
需要在项目根目录下创建配置文件:sonar-project.properties
If a sonar-project.propertiesfile cannot be created(or you won`t) in the root directory of the project, there are several alternatives:
如果无法在项目的根目录中创建sonar-project.properties文件(或者您不会),则有几种选择:
The properties can be specified directly through the command line. Ex:
sonar-scanner -Dsonar.projectKey=myproject -Dsonar.sources=src1
The property project.settings can be used to specify the path to the project configuration file (this option is incompatible with the project.home and sonar.projectBaseDir properties). Ex:
sonar-scanner -Dproject.settings=../myproject.properties
可以直接通过命令行指定属性。前任:
声纳扫描仪 -Dsonar.projectKey=myproject -Dsonar.sources=src1
属性 project.settings 可用于指定项目配置文件的路径(此选项与 project.home 和 sonar.projectBaseDir 属性不兼容)。前任:
声纳扫描仪 -Dproject.settings=../myproject.properties
The root folder of the project to analyze can be set through the sonar.projectBaseDirproperty since SonarQube Scanner 2.4 (was previously project.home). This folder must contain a sonar-project.propertiesfile if the mandatoryproperties (like sonar.projectKey) are not specified on the command line.
从 SonarQube Scanner 2.4(以前是 project.home)开始,可以通过sonar.projectBaseDir属性设置要分析的项目的根文件夹。如果命令行上未指定强制属性(如sonar.projectKey),则此文件夹必须包含sonar-project.properties文件。
Additional analysis parameterscan be defined in this project configuration file or through command-line parameters.
可以在此项目配置文件中或通过命令行参数定义其他分析参数。