Eclipse在pom.xml文件中显示错误:cvc-datatype-valid.1.2.1:'$ {MYVAR}'不是'boolean'的有效值 [英] Eclipse shows errors in pom.xml file: cvc-datatype-valid.1.2.1: '${MYVAR}' is not a valid value for 'boolean'

查看:2211
本文介绍了Eclipse在pom.xml文件中显示错误:cvc-datatype-valid.1.2.1:'$ {MYVAR}'不是'boolean'的有效值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Maven项目在命令行上构建良好。我想在Eclipse Luna 4.4.1中编辑项目文件,但是当我加载项目时,它会报告我的pom.xml文件中的以下错误:


cvc-datatype-valid.1.2.1:'$ {MYVAR}'不是'boolean'的有效值



cvc-type.3.1 .3:元素启用的'$ {MYVAR}'的值无效。


此问题看起来类似于< a href =https://stackoverflow.com/questions/24412567/validating-maven-pom-xml-when-boolean-is-a-property>当布尔属性为属性时验证Maven pom.xml ,这还没有任何答案。虽然我可以通过命令行上的Maven进行编译,但令人厌烦的是,Eclipse不断将这些报告作为错误报告。有没有办法摆脱这些错误,而不会禁用pom.xml文件的其余部分的验证?



根据 http://maven.apache.org/pom.html#Properties 我参考了 MYVAR



以下是我的pom.xml文件的相关内容:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/ XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< artifactId> myproject< / artifactId>
< groupId> org.mydomain< / groupId>
< packaging> jar< / packaging>
< version> 1.0-SNAPSHOT< / version>
<属性>
< spring-version> 3.0.2.RELEASE< / spring-version>
< MYVAR> false< / MYVAR>
< / properties>
< repositories>
< repository>
< id> internal_repo< / id>
< name>我的用于离线使用的内部存储库< / name>
< url> file:// $ {INT_REPO_HOME} / java / maven_repo< / url>
< layout> default< / layout>
< / repository>
< repository>
< id> central< / id>
< url> http://repo1.maven.org/maven2< / url>
< releases>
< enabled> $ {MYVAR}< / enabled>
< / releases>
< snapshots>
< enabled> $ {MYVAR}< / enabled>
< / snapshots>
< / repository>
< / repositories>
< / project>


解决方案

Eclipse正在验证POM的XSD,此XML元素的类型为布尔值。



布尔值的有效值为true / false,因此当它看到$ {MYVAR}时会引发验证错误...因为插件的Eclipse不会将变量从$ {MYVAR}转换为false。



但是,如果你做一个mvn安装它没有问题,意味着pom是正确的。



结论,这是一个Elipse插件问题,所以你只能忽略它。


I have a Maven project that builds fine on the command line. I want to edit the project files in Eclipse Luna 4.4.1, but when I load the project, it reports the following errors in my pom.xml file:

cvc-datatype-valid.1.2.1: '${MYVAR}' is not a valid value for 'boolean'

cvc-type.3.1.3: The value of '${MYVAR}' of element 'enabled' is not valid.

This problem looks similar to Validating Maven pom.xml when boolean is a property, which doesn't have any answers yet. While I can compile via Maven on the command line, it is annoying that Eclipse constantly reports these as errors. Is there any way to get rid of these errors without disabling the validation of the rest of the pom.xml file?

According to http://maven.apache.org/pom.html#Properties I'm referencing the MYVAR property correctly.

Here are the relevant contents of my pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>myproject</artifactId>
  <groupId>org.mydomain</groupId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <spring-version>3.0.2.RELEASE</spring-version>
    <MYVAR>false</MYVAR>
  </properties>
  <repositories>
    <repository>
      <id>internal_repo</id>
      <name>my internal repository for offline use</name>
      <url>file://${INT_REPO_HOME}/java/maven_repo</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
      <releases>
        <enabled>${MYVAR}</enabled>
      </releases>
      <snapshots>
        <enabled>${MYVAR}</enabled>
      </snapshots>
    </repository>
  </repositories>
</project>

解决方案

Eclipse is validating the XSD of the POM which says that this XML element is of type boolean.

Valid values for boolean are true/false so when it sees ${MYVAR} it raises a validation error... because the plugin of Eclipse doesn't do the variable translation from "${MYVAR}" to "false".

However if you do a mvn install it works with no problem, which means that the pom is correct.

Conclusion, this is an Elipse plugin issue so you can only ignore it.

这篇关于Eclipse在pom.xml文件中显示错误:cvc-datatype-valid.1.2.1:'$ {MYVAR}'不是'boolean'的有效值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆