SonarQube:“项目配置文件:无”

时间:2016-02-10 11:55:21

标签: java maven sonarqube sonar-runner sonarqube5.1

我已经配置了所有内容来对Maven项目进行声纳分析。一切都很好,直到我运行word_list = { "hello" : "1"} sentence= ['hello you, hows things', 'hello, good thanks'] newlist=[] for key, value in word_list.iteritems(): newlist=[x.replace(key,value) for x in sentence] print newlist

sonar-runner
  • 我在我的java项目文件夹
  • 中运行 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.
  • 我在我的java项目中放置并配置了sonar-runner

    sonar-runner.properties

有什么想法吗?

3 个答案:

答案 0 :(得分:4)

尝试传递这样的值:

sonar-runner -Dsonar.projectKey=..... -Dsonar.projectName=...

如果有效,则表示属性文件有些被忽略

如果您查看以下消息:

INFO: Scanner configuration file: /Users/Max/Documents/sonar-scanner-2.5/conf/sonar-runner.properties
INFO: Project configuration file: NONE

您的项目配置文件似乎确实被忽略了

答案 1 :(得分:4)

我遇到了同样的问题而且我意识到我的文件名不正确:而不是“sonar-project.properties”我把它作为“sonar-project.properties.properties”。

我会尝试将您的文件名更改为“sonar-project.properties”并尝试...

答案 2 :(得分:0)

您需要在项目的根目录中创建一个configuration file sonar-project.properties

如果无法在项目的根目录中创建 sonar-project.properties 文件(或者您不会),则出现several alternatives

  • 可以直接通过命令行指定属性。例如:

    sonar-scanner -Dsonar.projectKey = myproject -Dsonar.sources = src1

  • 属性project.settings可用于指定指向的路径。 项目配置文件(此选项与 project.home和sonar.projectBaseDir属性)。例如:

    sonar-scanner -Dproject.settings = .. / myproject.properties

自SonarQube Scanner 2.4(以前是project.home)以来,可以通过 sonar.projectBaseDir 属性设置要分析的项目的根文件夹。如果未在命令行上指定强制属性(例如 sonar.projectKey ),则此文件夹必须包含 sonar-project.properties 文件。

可以在此项目配置文件中或通过命令行参数定义

Additional analysis parameters