簡體   English   中英

Groovy Codenarc.xml org.xml.sax.SAXParseException xsi:schemaLocation與元素類型規則集未綁定

[英]Groovy Codenarc.xml org.xml.sax.SAXParseException xsi:schemaLocation not associated with element type ruleset not bound

我正在使用Gradle 2.3,並且項目具有Groovy代碼。 對於靜態代碼分析,我使用Codenarc(即項目文件夾中包含“ config / codenarc / codenarc.xml”文件)。

在build.gradle / GRADLE_HOME / init.d / top-level.gradle文件中,我有:

apply plugin: 'codenarc'

   codenarc {
     ignoreFailures = true
     configFile = file("config/codenarc/codenarc.xml")
   }

但是在編譯該項目時,出現以下錯誤。

13:49:00 :codenarcAcceptanceTest UP-TO-DATE
13:49:01 :codenarcIntegrationTest FAILED
13:49:01 
13:49:01 FAILURE: Build failed with an exception.
13:49:01 
13:49:01 * What went wrong:
13:49:01 Execution failed for task ':codenarcIntegrationTest'.
13:49:01 > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 173; The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "ruleset" is not bound.
13:49:01 
13:49:01 * Try:
13:49:01 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
13:49:01 
13:49:01 BUILD FAILED

codenarc.xml文件中的文件內容為:

<ruleset xsi:schemaLocation="http://codenarc.org/ruleset/1.0 http://codenarc.org/ruleset-schema.xsd" xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">
   <description>Sample rule set</description>
   <ruleset-ref path="rulesets/basic.xml"/>
   <ruleset-ref path="rulesets/braces.xml">
      <rule-config name="IfStatementBraces">
         <property name="priority" value="3"/>
      </rule-config>
   </ruleset-ref>
   <ruleset-ref path="rulesets/concurrency.xml"/>
  <ruleset-ref path="rulesets/convention.xml"/>
   <ruleset-ref path="rulesets/design.xml"/>
   <ruleset-ref path="rulesets/dry.xml">
      <rule-config name="DuplicateStringLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <rule-config name="DuplicateNumberLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <rule-config name="DuplicateMapLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <rule-config name="DuplicateListLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
   </ruleset-ref>
   <ruleset-ref path="rulesets/exceptions.xml"/>
   <ruleset-ref path="rulesets/formatting.xml"/>
   <ruleset-ref path="rulesets/generic.xml"/>
   <ruleset-ref path="rulesets/grails.xml"/>
   <ruleset-ref path="rulesets/groovyism.xml"/>
   <ruleset-ref path="rulesets/imports.xml">
      <exclude name="MisorderedStaticImports"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/jdbc.xml"/>
   <ruleset-ref path="rulesets/junit.xml"/>
   <ruleset-ref path="rulesets/logging.xml"/>
   <ruleset-ref path="rulesets/naming.xml">
      <rule-config name="FieldName">
         <property name="ignoreFieldNames" value="log"/>
      </rule-config>
      <rule-config name="MethodName">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <exclude name="FactoryMethodName"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/security.xml">
      <exclude name="JavaIoPackageAccess"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/serialization.xml"/>
   <ruleset-ref path="rulesets/size.xml"/>
   <ruleset-ref path="rulesets/unnecessary.xml">
      <exclude name="UnnecessaryPackageReference"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/unused.xml"/>
</ruleset>

xml不知道您使用了什么xsi作為來自正確名稱空間url的前綴。 嘗試以下標頭:

<ruleset xmlns="http://codenarc.org/ruleset/1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://codenarc.org/ruleset/1.0 http://codenarc.org/ruleset-schema.xsd"
    xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">

暫無
暫無

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

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