我想告诉 Eclipse 不要格式化 pom.xml
属性。
在我的示例中,我将一个长 proxyString 参数附加到 Maven 发布插件:
</build>
</plugins>
(...)
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<!-- in case of error while release prepare or dryRun release :
check proxyString should be on one line (withour CR) -->
<configuration>
<arguments>${proxyString}</arguments>
</configuration>
</plugin>
</plugins>
</build>
当我重新格式化 pom.xml
时,Eclipse 会在该定义中附加一些回车符:
<profile>
<id>proxy</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<proxyString>-Djava.net.useSystemProxies=true -Dhttp.proxyHost=myProxy -Dhttp.proxyPort=3128 -Dhttps.proxyHost=myProxy -Dhttps.proxyPort=3128</proxyString>
</properties>
</profile>
这会导致发布生命周期中断:
No goals have been specified for this build. You must specify a valid lifecycle phase
是否存在一种方法来告诉 Eclipse 不要格式化 pom.xml 的一部分? (或者也许有更好的方法将代理设置转发到 Maven 发布插件)。
我知道这个question非常接近我的,但我没有找到如何将它应用到 xml 文件。
最佳答案
您可以选择要格式化的 pom 部分,然后按
CTRL + SHIFT + F
当您按“CTRL + SHIFT + F”而不选择时,它将格式化整个文件。
选择后将仅格式化选定的部分。
关于java - 如何关闭 maven pom.xml 某些部分的 Eclipse 代码格式化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31850432/