0

关于生成 JAXB 对象的两个问题。

如两个示例中所示配置 Jaxb 时有什么区别。

使用 Maven

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>src/main/webapp/WEB-INF/schemas</schemaDirectory>
                </configuration>
            </plugin>

使用 Spring 配置文件

 <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPath" value="org.springframework.ws.samples.mtom.schema"/>
        <property name="mtomEnabled" value="true"/>
    </bean>

上述两种配置是否实现了同样的事情?

第二个问题是如何使用 Maven 配置方法启用 MTOM?

4

1 回答 1

1

它们是两种完全不同的东西。

maven 插件将在 generate-sources maven 阶段根据您的模式文件自动生成您的 jaxb 实体。

第二个配置设置 jaxb 编组器并告诉它 jaxb 实体位于该 contextPath 中。

所以本质上 Maven 是构建时间,第二个配置是运行时

你的第二个问题。MTOM与maven无关。他们让我工作的方法是下载 spring-ws 代码,那里有一个很好的示例,非常有帮助。

于 2012-07-11T21:37:18.637 回答