0

I'm new of maven this is the first time that I'm using maven-jaxb2-plugin to generate java classes from a .xsd schema.

This is my pom.xml:

 <properties>
    <java.source.version>1.6</java.source.version>
    <java.target.version>1.6</java.target.version>
 </properties>
 <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${java.source.version}</source>
                <target>${java.target.version}</target>
            </configuration>

        </plugin>


        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.8.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <schemaDirectory>src/main/resources/schema</schemaDirectory>
                <schemaIncludes>
                    <include>mySchema.xsd</include>
                </schemaIncludes>
                <generatePackage>it.mycompany.jaxb2</generatePackage>
                <readOnly>true</readOnly>
            </configuration>
        </plugin>
    </plugins>
    </build>    
<dependencies>
    <!-- A few dependiences -->
</dependencies>

The trouble is that when i try to run

mvn install

i get the following error

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.8.3:generate failed: Illegal pattern character 'g'
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
  Caused by: java.lang.IllegalArgumentException: Illegal pattern character 'g'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:768)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:575)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:500)
at com.sun.tools.xjc.Options.getPrologComment(Options.java:937)
at com.sun.tools.xjc.addon.episode.PluginImpl.run(PluginImpl.java:177)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:294)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:70)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:45)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:29)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:318)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:160)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
... 21 more

Maven is configured in this way:

mvn --version Maven home: C:\Program Files (x86)\apache-maven-3.1.1\bin.. Java version: 1.6.0_45, vendor: Sun Microsystems Inc. Java home: C:\Program Files (x86)\Java\jdk1.6.0_45\jre Default locale: it_IT, platform encoding: Cp1252 OS name: "windows 8", version: "6.2", arch: "x86", family: "windows"

Where am I doing wrong?

4

1 回答 1

1

问题是 maven-jaxb2-plugin 默认使用的是 jaxb-xjc 的 2.2.6 版本,这个版本有一些问题

默认语言环境:it_IT

但仅适用于美国语言环境。然后我在我的pom上添加了以下依赖

  <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-xjc</artifactId>
    <version>2.2.5</version>
  </dependency>

现在一切正常。

于 2014-02-25T11:18:24.597 回答