【问题标题】:Maven resource filtering breaks unicode escape in resource bundleMaven 资源过滤破坏了资源包中的 unicode 转义
【发布时间】:2020-09-04 07:47:14
【问题描述】:

我们的应用程序有一个资源包,我们需要将变音符号写成转义的 unicode 值(\u00f6 表示 ö)。

因为对于某些构建,我们需要不同的文本,并且为了不必复制其他 maven 配置文件的所有资源文件,我添加了一个 maven 过滤器文件,它将相应的文本放入资源包属性文件( webResources 的 Maven 战争插件)。这很好用,除了在过滤期间 maven 将我的 \u00f6 转换为 ö 并因此破坏了我们的资源包。

mylan.properties:
myMessage.title=${myProperty.to.replace}

-> 使用 filter.properties 过滤:
myProperty.to.replace=只显示一些\u00f6。

-> 结果:
myMessage.title=只显示一些ö。

但应该是:
myMessage.title=只显示一些\u00f6。

如何告诉 maven 在过滤 webResources 期间不要进行此替换?

感谢您的任何提示!
奥雷尔

这是我用于打包的 maven 配置:

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>3.0.0</version>
                        <configuration>
                            <classifier>XYZ</classifier>
                            <warName>${project.artifactId}${svn_revision.padded}</warName>
                            <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                            <filters>src/main/config/filter.properties</filters>
                            <webResources>
                                ...
                                <resource>
                                    <!-- needs to be here because of env dependent filtering -->
                                    <filtering>true</filtering>
                                    <directory>src/main/resources</directory>
                                    <targetPath>WEB-INF/classes</targetPath>
                                </resource>
                                ...
                            </webResources>
                        </configuration>
                    </plugin>

【问题讨论】:

    标签: maven filtering resourcebundle unicode-escapes


    【解决方案1】:

    【讨论】:

    • 是的,这就是重点。我错过了那个。最后,我必须在每个 unicode 字符前加上转义字符:\\u00e0 而不是 \u00e0 用于替换属性中的“à”。非常感谢!
    猜你喜欢
    • 2016-08-16
    • 1970-01-01
    • 2011-05-02
    • 2020-01-07
    • 2013-04-11
    • 2016-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-12-21
    相关资源
    最近更新 更多