我试图使用maven版本插件自动更新我的所有依赖项。不过,我不想要alpha或beta版本。因此,我创建了一个“规则文件”来排除这些版本。下面是:
<ruleset comparisonMethod="maven"
xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<rule groupId="commons-logging" artifactId="commons-logging">
<ignoreVersions>
<ignoreVersion type="regex">.*[-_\.](alpha|Alpha|ALPHA|b|beta|Beta|BETA|rc|RC|M|EA)[-_\.]?[0-9]*</ignoreVersion>
</ignoreVersions>
</rule>
</ruleset>(这个正则表达式来自这条线。)
问题是Intellij使xmlns URI和第二个xsi:schemaLocation变为红色,表示"URI未注册“,而对于第二个URI”无法解决符号'http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd'“。文献资料使用相同的值,所以我假设它们是商品。
我如何注册这个URI,然后修补不可解析的符号?
谢谢!
发布于 2017-08-17 08:31:43
我发现实际的模式不是位于http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd,而是在这里:http://www.mojohaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd
文档(http://www.mojohaus.org/versions-maven-plugin/version-rules.html)实际上给出了一个错误的示例文件,但确实声明了以下内容
规则集文件必须与XSD模式匹配.
这意味着应该将xsi:schemaLocation更改为
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://www.mojohaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd"完整地说,这就是:
<ruleset
comparisonMethod="maven"
xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://www.mojohaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<rule groupId="commons-logging" artifactId="commons-logging">
<ignoreVersions>
<ignoreVersion type="regex">.*[-_\.](alpha|Alpha|ALPHA|b|beta|Beta|BETA|rc|RC|M|EA)[-_\.]?[0-9]*</ignoreVersion>
</ignoreVersions>
</rule>
</ruleset>更改xsi:schemaLocation后,可以使用<Alt>+<Enter>并选择“获取外部资源”来解析架构并导入正确的命名空间。
另一种选择是:
您还可以告诉IntelliJ您认为模式位于何处。例如,您可以将文件下载到磁盘;按<Alt>+<Enter>,选择“手动设置外部资源”并指向您刚刚下载的文件。IntelliJ IDEA现在应该忽略xsi:schemaLocation提示,并使用您刚刚配置的覆盖。
使用指向远程文件的xsi:schemaLocation的缺点是,xml处理器每次都必须动态下载它(这是性能的问题,特别是如果模式本身也指向外部模式的话)。其次,由于它不是http的,所以您必须相信文件在传输中没有被修改。通过预先下载该文件,您可以检查该文件,将其放置在可信位置并使用该已知版本。
https://stackoverflow.com/questions/44135921
复制相似问题