【问题标题】:JAXB maven project in eclipse keeps giving me localized error messageseclipse中的JAXB maven项目不断给我本地化错误消息
【发布时间】:2015-12-03 17:19:37
【问题描述】:

tl;dr:如何使用本地化(德语)错误消息停止 maven?

我在 Eclipse 中有一个 maven 项目,我仅用于从 xsds 创建 jaxb 类(使用上下文菜单中的 Run as-> Maven generate-sources)。有一些问题,我正在尝试解决它们,但由于某种原因,我的系统发现用德语给我错误消息是个好主意。这些对于在互联网上寻求帮助根本没有帮助。

我的 Windows 是德语版本,但我的 eclipse 不是,我没有在 pom 中指定使用德语(我也没有指定使用英语 - 谷歌搜索“maven pom set language”只告诉我如何指定一个 java 版本)。

我不知道是否有可能,我的 maven 正在将 jar 的本地化版本提取到我的 maven 存储库。如果是这样的话,我希望它停止这样做。

有人知道如何阻止 maven/java/eclipse/jaxb 提供德语错误消息吗?我已经厌倦了不得不猜测英文文本会是什么。

附加信息

我的pom.xml 仿照https://stackoverflow.com/a/2857613/1358283。这是<build> 部分:

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.12.3</version>
            <executions>
                <execution>
                    <id>generate-schema-statusinformation</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <generateDirectory>target/msg</generateDirectory>
                        <schemaDirectory>${schemaBaseDir}/xsds/StatusInformation</schemaDirectory>
                        <generatePackage>${schemaBasePackage}.statusinformation</generatePackage>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

这是我的(匿名)错误输出的一部分,带有部分德语文本:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building My-Messages 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-jaxb2-plugin:0.12.3:generate (xxx) @ my-messages ---
[INFO] Up-to-date check for source resources [[file:/C:/xxx/StatusInformation.xsd, file:/C:/xxx/pom.xml]] and taret resources [[]].
[INFO] Sources are not up-to-date, XJC will be executed.
[ERROR] Error while parsing schema(s).Location [ file:/C:/xxx/StatusInformation.xsd{493,60}].
com.sun.istack.SAXParseException2; systemId: file:/C:/xxx/StatusInformation.xsd; lineNumber: 493; columnNumber: 60; Element "Remarks" ist in mehr als einer Eigenschaft vorhanden.
    at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:86)
    at com.sun.tools.xjc.reader.ModelChecker.check(ModelChecker.java:92)
...

(这个问题不是为了寻找特定错误的帮助,只针对语言问题)

【问题讨论】:

    标签: java eclipse maven pom.xml


    【解决方案1】:

    xjc 包含错误消息的本地化文本资源和插入生成文件的 cmets,因此适用于区域设置解析的常用规则。

    Java VM 的语言环境由 user.language 系统属性定义,该属性在 Unix 系统上从 LANG 环境变量初始化。

    (我没有Windows,所以你必须自己找出相应的设置。)

    要覆盖我系统上的德语默认设置,我只需像这样调用 Maven:

    LANG=en mvn clean install
    

    当使用 运行时 | Maven build 在 Eclipse 中,您可以在 Maven 启动配置的 Environment 选项卡上设置此环境变量。

    【讨论】:

    • 设置语言就可以了。我最终做的是将-Duser.language=en 添加到我的 JRE 的默认 VM 参数中。
    • 我在使用 STS 的 Spring Boot 中遇到了同样的问题 @kratenko 提示解决了我的问题
    猜你喜欢
    • 2015-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-09
    • 1970-01-01
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多