Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Spring Jaxb2Marshaller生成动态名称空间前缀_Java_Spring Boot_Jaxb_Jaxb2_Spring Oxm - Fatal编程技术网

Java 使用Spring Jaxb2Marshaller生成动态名称空间前缀

Java 使用Spring Jaxb2Marshaller生成动态名称空间前缀,java,spring-boot,jaxb,jaxb2,spring-oxm,Java,Spring Boot,Jaxb,Jaxb2,Spring Oxm,我使用SpringJaxb2Marshaller将java对象转换为XML,反之亦然。考虑到示例,我需要为xmlns前缀和值设置动态值 xmlns:abc="http://www.example.com" 其中前缀为abc 和值为http://www.example.com必须是可配置的(从属性文件提供) 请参阅包com.test.abc <abc:Product xmlns:abc="http://www.example.com" xmlns:xsi="http://

我使用Spring
Jaxb2Marshaller
将java对象转换为XML,反之亦然。考虑到示例,我需要为
xmlns
前缀和
值设置动态值

xmlns:abc="http://www.example.com"
其中
前缀
abc
http://www.example.com
必须是可配置的(从属性文件提供)

请参阅包
com.test.abc

<abc:Product 
    xmlns:abc="http://www.example.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <abc:productId>252</abc:productId>
    <abc:productName>XYZ</abc:productName>
</abc:Product>
这里是硬编码的xmlns前缀和值。我需要提供这些服务 属性文件中的xmlns前缀和值。我怎样才能做到这一点

我使用的是SpringBoot 1.3.3

@Bean
public Jaxb2Marshaller getJaxb2Marshaller(){
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setPackagesToScan("com.test.abc", "com.test.xyz");
    Map<String,Object> propertiesMap = new HashMap<String,Object>();
    propertiesMap.put("jaxb.formatted.output", true);
    marshaller.setMarshallerProperties(propertiesMap);
    return marshaller;
}
@javax.xml.bind.annotation.XmlSchema(
    namespace = "http://www.example.com", 
    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
    xmlns = { @javax.xml.bind.annotation.XmlNs(namespaceURI = "http://www.example.com", prefix="abc")})
package com.test.abc;