如何使用jaxb2 maven插件生成@TABLE标记

如何使用jaxb2 maven插件生成@TABLE标记,jaxb,maven-jaxb2-plugin,jaxb2-basics,Jaxb,Maven Jaxb2 Plugin,Jaxb2 Basics,您好,我已经学习了一些教程,并编写了一个模式,如下所示: <xs:element name="User" type="kmcs:User"/> <xs:element name="UserList" type="kmcs:UserList"/> <xs:complexType name="User"> <xs:sequence> <xs:element name="id" ty

您好,我已经学习了一些教程,并编写了一个模式,如下所示:

<xs:element name="User" type="kmcs:User"/>
    <xs:element name="UserList" type="kmcs:UserList"/>

    <xs:complexType name="User">
        <xs:sequence>
                <xs:element name="id" type="xs:long" minOccurs="0" />
                <xs:element name="name" type="xs:string" />
                <xs:element name="registrationDate" type="xs:dateTime" />
            </xs:sequence>
            <xs:attribute name = ""/>

    </xs:complexType>

    <xs:complexType name="UserList">
        <xs:complexContent>
            <xs:extension base="kmcs:User">
                <xs:sequence>
                   <xs:element name="user"  minOccurs="0"
                maxOccurs="unbounded" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>


</xs:schema>
我想要这样的东西:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "User", propOrder = {
    "id",
    "name",
    "registrationDate"
})
@XmlSeeAlso({
    UserList.class
})
@Entity
@XmlRootElement(name ="user")
@Table(schema = "schema_name", uniqueConstraints = {

}, name = "User")
public class User
    implements Serializable, ToString
{

因此,我想要的基本上是表名,它选择我提供的硬编码的任何内容,但我希望它显示类名或类对象名。

使用此配置

    <bindings version="2.0" xmlns="http://java.sun.com/xml/ns/jaxb"
        xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
        xmlns:annox="http://annox.dev.java.net"
        xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix">
        <bindings schemaLocation="../yourSchema.xsd">

            <bindings node="//xs:complexType[@name='User']">
                <annox:annotate>
                    <annox:annotate annox:class="javax.persistence.Entity">
                    </annox:annotate>
                    <annox:annotate annox:class="javax.persistence.Table" schema = "schema_name" name = "User">
                    </annox:annotate>
                    <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
                    name="User">
                    </annox:annotate>
                </annox:annotate>
            </bindings>

        </bindings>
    </bindings>
maven插件配置是

            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.8.1</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <args>
                        <arg>-Xannotate</arg>
                        <arg>-nv</arg>
                        <arg>-Xnamespace-prefix</arg>
                    </args>
                    <extension>true</extension>
                    <schemaDirectory>src/main/resources/schema</schemaDirectory>
                    <schemaIncludes>
                        <schemaInclude>yourSchema.xsd</schemaInclude>
                    </schemaIncludes>
                    <bindingDirectory>src/main/resources/schema/xjb</bindingDirectory>
                    <bindingIncludes>
                        <include>*.xjb</include>
                    </bindingIncludes>
                    <debug>true</debug>
                    <verbose>true</verbose>
                    <episode>true</episode>
                    <forceRegenerate>true</forceRegenerate>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.6.0</version>
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics-annotate</artifactId>
                            <version>0.6.0</version>
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-namespace-prefix</artifactId>
                            <version>1.1</version>
                        </plugin>
                    </plugins>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate.javax.persistence</groupId>
                        <artifactId>hibernate-jpa-2.0-api</artifactId>
                        <version>1.0.1.Final</version>
                    </dependency>
                </dependencies>
            </plugin>

你解决这个问题了吗?如果是,您是如何解决的?
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.8.1</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <args>
                        <arg>-Xannotate</arg>
                        <arg>-nv</arg>
                        <arg>-Xnamespace-prefix</arg>
                    </args>
                    <extension>true</extension>
                    <schemaDirectory>src/main/resources/schema</schemaDirectory>
                    <schemaIncludes>
                        <schemaInclude>yourSchema.xsd</schemaInclude>
                    </schemaIncludes>
                    <bindingDirectory>src/main/resources/schema/xjb</bindingDirectory>
                    <bindingIncludes>
                        <include>*.xjb</include>
                    </bindingIncludes>
                    <debug>true</debug>
                    <verbose>true</verbose>
                    <episode>true</episode>
                    <forceRegenerate>true</forceRegenerate>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.6.0</version>
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics-annotate</artifactId>
                            <version>0.6.0</version>
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-namespace-prefix</artifactId>
                            <version>1.1</version>
                        </plugin>
                    </plugins>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate.javax.persistence</groupId>
                        <artifactId>hibernate-jpa-2.0-api</artifactId>
                        <version>1.0.1.Final</version>
                    </dependency>
                </dependencies>
            </plugin>