我必须生成一个WS客户端,我无法决定使用哪个插件.到目前为止,我的选择是:jaxb2-maven-plugin,axistools-maven-plugin和jaxws-maven-plugin.
在Helios/m2eclipse下,当我生成jaxb源时,当我执行"更新项目配置"时,它们将被放在Eclipse源路径上.
Indigo/m2e(2011年6月22日首次发布)不会发生这种情况.我需要做些什么来解决这个问题?
我正在使用标准的maven-jaxb2-plugin,版本0.75.
我有几十个和几十个.xsd我想自动生成代码的文件.当我尝试同时生成所有文件时,一些文件具有重复的名称.
我专注于尝试让其中的两个工作.
当我得到这两个工作时,我会解决剩下的问题.但我现在只关注其中的两个文件.我无法控制它们,它们来自供应商并遵循"标准",因此编辑它们不是出于多种原因的选择.
我正在使用它maven-jaxb2-plugin来处理这些文件.
我添加了一个binding.xjb文件,如mat b我在网站上找到的答案和其他说明中的链接所示.但我得到以下错误,没有输出.
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="2.1"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd">
<jxb:bindings schemaLocation="mac-3.4.xsd">
<jxb:schemaBindings>
<jxb:package name="my.company.mac"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="mac-stylesheet-3.4.xsd">
<jxb:schemaBindings>
<jxb:package name="my.company.stylesheet"/>
</jxb:schemaBindings>
</jxb:bindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)
出现以下错误
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/Jarrod%20Roberson/Projects/spa-tools/spa-lib/src/main/sc
hema/mac-stylesheet-3.4.xsd{165,33}].
org.xml.sax.SAXParseException: 'halign' is already defined
Run Code Online (Sandbox Code Playgroud)
令人不快的元素是:(还有很多其他的只是第一个发生冲突的因素)
<xsd:simpleType name="halign">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="left" />
<xsd:enumeration value="center" />
<xsd:enumeration value="right" />
</xsd:restriction>
</xsd:simpleType>
Run Code Online (Sandbox Code Playgroud)
并且在每个.xsd文件中都是相同的,如何使用仅生成一个类或者将每个类生成到其自己的包命名空间中来解决此重复问题? …
我有客户端提供的WSDL和模式文件.我需要使用此WSDL文件创建Spring-boot SOAP Web服务.我有谷歌它和我能找到的所有例子,他们用spring自动生成wsdl.我如何使用我的WSDL生成SOAP服务?
我有一个基于Maven的项目,我尝试添加一些由"jaxb2-maven-plugin"Maven插件自动生成的JAXB类.但是,我的第一个剪辑让我进入循环依赖循环:
似乎有两种明显的可能性来解决这个问题:
/target到/src/main/java,以便对它们的引用不会导致编译错误.我在这里错过了什么吗?选项#1看起来很荒谬......这不是人们使用JAXB的方式.选项#2似乎更合理,但仍然相当低效和繁琐.我真的不得不承担一个完全独立的项目的开销只是为了使用JAXB?
开发人员是否有更优雅的方法在Maven插件生成它们的同一个项目中引用JAXB生成的类?
更新: 根据要求,这是我的POM的相关部分:
<build>
<plugins>
<plugin>
<!-- configure the compiler to compile to Java 1.6 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<packageName>com.mypackage</packageName>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
当我运行时mvn clean package,我会看到我的JAXB源是在/target子目录下生成的.但是,这些生成的源不会自动添加到编译阶段的类路径中.
POST-RESOLUTION UPDATE: 事实证明我的编译问题更多地与我在Eclipse中运行的事实有关,而且它的Maven集成在"jaxb2-maven-plugin"中存在一些问题.有关该问题及其解决方案的更多详细信息,请参阅此StackOverflow问题.
我正在尝试使用jaxb2-maven-plugin maven插件从xsd生成bean,但是每次生成bean时都会收到以下警告.请注意,结果bean工作.有谁知道为什么会这样?
--snip--
[INFO] task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [jaxb2:xjc {execution: default}]
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
[WARNING] null[-1,-1]
org.xml.sax.SAXParseException: generating code
at com.sun.tools.xjc.ErrorReceiver.debug(ErrorReceiver.java:113)
at com.sun.tools.xjc.Driver.run(Driver.java:315)
at org.codehaus.mojo.jaxb2.XjcMojo.execute(XjcMojo.java:301)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
--snip--
Run Code Online (Sandbox Code Playgroud)
这是pom.xml中的配置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.some.package.jaxb</packageName>
<verbose>true</verbose>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
虽然我认为我在技术上使用2.0.3(而不是2.0),但这是启动此问题的代码行:http: //grepcode.com/file/repo1.maven.org/maven2/com.sun.xml .bind/JAXB的XJC/2.0/COM /阳光/工具/ XJC/Driver.java#315
**如果我在pom中将verbose设置为false,则不会收到警告.这只是一个草率的记录机制吗?**
谢谢
--Matthias
java ×3
jaxb ×3
maven ×2
maven-plugin ×2
axis ×1
java-ee ×1
jax-ws ×1
m2e ×1
m2eclipse ×1
soap ×1
spring-boot ×1
spring-oxm ×1
spring-ws ×1