我有问题maven-jaxb2-plugin.我想要实现的是从x个不同的wsdl生成源到不同的包.
我想避免使用多个方法,<execution>所以当我添加另一个wsdl时,我可以保持pom.xml不变.
我配置了像这样的maven插件:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemaDirectory>src/main/resources/webservice/wsdl</schemaDirectory>
<schemaIncludes>
<include>orig/*.wsdl</include>
</schemaIncludes>
<bindingDirectory>src/main/resources/webservice/xjb</bindingDirectory>
<bindingIncludes>
<include>orig/*.xjb</include>
</bindingIncludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在我的理解中,这种方式我指定了.wsdl位置以及绑定文件位置.
现在在一个示例绑定文件中(所有这些都以相同的方式构造)我得到以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:version="2.1">
<jaxb:bindings schemaLocation="../../wsdl/orig/soap1.wsdl"
node="*/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="my.package.com.soap1" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)
另一项服务是soap2,soap3等,它们都有类似的绑定文件.如果我理解这是正确的,多亏了这个connfig我应该能够在单独的包中为我的肥皂生成域对象.
但是当我运行时,maven clean compile我得到以下输出:
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/me/workspace/orig-project/src/main/resources/webservice/wsdl/orig/soap1.wsdl{202,39}].
org.xml.sax.SAXParseException; systemId: file:/C:/Users/me/workspace/orig-project/src/main/resources/webservice/wsdl/orig/soap1.wsdl; lineNumber: 202; columnNumber: 39; 'Line' **is already defined**
Run Code Online (Sandbox Code Playgroud)
更重要的是,出于测试目的,我尝试配置插件来单独处理每个wsdl <execution>(我想在最终代码中避免这种情况),我观察到的是在第一个ex之后.处理了soap1.wsdl,正确创建了包,但根本没有创建其他soap.wsdl的包.(只有第一次处理). …
这次我正在使用Declarative REST Client,在一些Spring Boot App中使用Feign.
我想要实现的是调用我的一个REST API,它看起来像:
@RequestMapping(value = "/customerslastvisit", method = RequestMethod.GET)
public ResponseEntity customersLastVisit(
@RequestParam(value = "from", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date from,
@RequestParam(value = "to", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date to) {
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,API接受带有from和to params的调用,格式为 (yyyy-MM-dd)
为了调用该API,我准备了以下部分@FeignClient:
@FeignClient("MIIA-A")
public interface InboundACustomersClient {
@RequestMapping(method = RequestMethod.GET, value = "/customerslastvisit")
ResponseEntity customersLastVisit(
@RequestParam(value = "from", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date from,
@RequestParam(value = "to", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date to); …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何实现以下映射:
class SuperComplexClass {
Long value;
String description;
}
class MapIntoMe {
// Many other fields that is also mapped
SuperComplexClass superComplexObject;
}
class MapFromMe {
ComplexClassPart1 complexClassPart;
}
class AdditionalData {
ComplexClassPart2 complexClassPart;
}
@Mapper
public interface SomeFancyMapper {
@Mapping(target = "superComplexObject", source = "{mfm.complexPart, ad.complexPart}",
qualifiedByName = "mapSuperComplexObject")
MapIntoMe mapFromMeIntoMe(MapFromMe mfm, AdditionalData ad);
@Named("mapSuperComplexObject")
default SuperComplexClass mapSuperComplexObject(ComplexPart1 p1, ComplexPart2 p2) {
SuperComplexClass superObject = new SuperComplexClass();
//some logic that calculates and fills superObject]
return superObject;
}
}
Run Code Online (Sandbox Code Playgroud)
现在显然这样的表达 …