Unfortunately, it seems like Spring XD doesn't ship with XML type converter ( application/xml
).
I implemented 2 AbstractFromMessageConverter
s for converting POJO to XML and vice versa.
According to documentation it says to look at streams.xml where I think they were really referring to this XML. I provided a list named customMessageConverters
and my own Configuration which exposes these converters in an attempt to add them to Spring XD application context.
I wrote:
@Configuration
@Slf4j
public class XmlConverterConfiguration {
@Bean
public CompositeMessageConverter compositeMessageConverter(final MessageConverter[] converters) {
log.info("Registering XML converters");
return new CompositeMessageConverter(Arrays.asList(converters));
}
}
And I added @Component
annotation to my Converters.
And also this XML:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Users can override this to add converters.-->
<util:list id="customMessageConverters">
<bean class="my.custom.mime.converter.PojoToXmlMessageConverter"/>
<bean class="my.custom.mime.converter.XmlToPojoMessageConverter"/>
</util:list>
</beans>
and I tried adding this XML to src/main/resources
and src/main/resources/config
and then I put the compiled .jar to $XD_HOME/lib
but it doesn't get registered properly.
I don't see the log from my Configuration and when I try to set outputType to application/xml
I get an exception that it isn't supported:
org.springframework.xd.dirt.plugins.ModuleConfigurationException: Content type is not supported for outputType=application/xml
What step did I do wrong?
--EDIT--
I also uncommented these lines in server.yml
and changed the basepackages to mine.
---
# User Extensions: Where XD scans the classpath to discover extended container configuration to add beans to the Plugins context.
# Each property may be a comma delimited string. 'basepackages' refers to package names used for
# annotated component (@Configuration or @Component stereotypes) scanning. 'locations' is a list of root resource directories containing XML or Groovy configuration.
# XD prepends classpath:* if no prefix included and appends **/*.* to each location
xd:
extensions:
basepackages: my.custom.mime.converter
locations: META-INF/spring-xd/ext
---
You have to put the file in a narrow folder, eg /myCustomConverters
in the jar; then you have to tell XD how to find it by uncommenting the configuration in serverys.yml
...
# User Extensions: Where XD scans the classpath to discover extended container configuration to add beans to the Plugins context.
# Each property may be a comma delimited string. 'basepackages' refers to package names used for
# annotated component (@Configuration or @Component stereotypes) scanning. 'locations' is a list of root resource directories containing XML or Groovy configuration.
# XD prepends classpath:* if no prefix included and appends **/*.* to each location
xd:
extensions:
# basepackages: com.acme.xd.extensions
# locations: META-INF/spring-xd/ext
locations: myCustomConverters
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.