簡體   English   中英

使用 JAXB 生成類時的問題 - 沒有 @XmlRootElement

[英]Problems when generating classes with JAXB - no @XmlRootElement

當我運行 JAXB 插件時,會創建文件,但沒有 @XmlRootElement 出於這個原因,除了向類添加“擴展”之外,我還需要手動包含此注釋,但是每當項目更新時,更改都會撤消:

@XmlRootElement
public class BuscarVeiculo extends BuscarGenericDao {

我的 pom.xml 看起來像這樣:

         <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.14.0</version>               
            <executions>
                <execution>
                    <id>veiculo</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>                    
                    <configuration>
                        <schemaLanguage>WSDL</schemaLanguage>
                        <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
                        <schemaIncludes>
                            <include>VeiculoWS.wsdl</include>
                        </schemaIncludes>
                        <generatePackage>com.pmdf.soap.api.soap.project.veiculo</generatePackage>
                        <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
                    </configuration>
                </execution>    
            </executions>
        </plugin>

在下面的代碼中,我撥打了電話:

@Service
public class SoapClientService {

    @Autowired
    private Jaxb2Marshaller marshaller;

    private WebServiceTemplate template;

    public JAXBElement<?>  findMyObject(FindGenericDao request, String URI) {

        template = new WebServiceTemplate(marshaller);
        JAXBElement<?> vehicle = (JAXBElement<?>) template.marshalSendAndReceive(URI , request);

        return vehicle;
    }

}

我使用錯誤的插件來處理wsdl,實際上我應該使用jaxws-maven-plugin。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM