我正在处理一个项目(spring boot),我必须使用 maven jaxb2 插件将 xml 文件转换为 Java 类。我正在关注此链接:生成类,问题是当我尝试解组 xml 时出现此错误:Resource ServletContext resource [/xsd/MX_seev_031_001_05. xsd] 不存在 这是我的 application.properties:
context.path =xml.swift.spring.com
schema.location= xsd/MX_seev_031_001_05.xsd
Run Code Online (Sandbox Code Playgroud)
这是我的配置 bean:
@Bean
public Jaxb2Marshaller createJaxb2Marshaller(@Value("${context.path}") final String contextPath,
@Value("${schema.location}") final Resource schemaResource){
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(contextPath);
marshaller.setSchema(schemaResource);
Map<String, Object> properties = new HashMap<>();
properties.put(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setMarshallerProperties(properties);
return marshaller;
Run Code Online (Sandbox Code Playgroud)
xsd 文件在 src/main/resources/xsd 下,这是我的 pom.xml:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.1</version>
<executions>
<execution>
<id>add-source-for-demoapp</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/xsd</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<!-- Other configuration options-->
</configuration>
</execution>
</executions> …
Run Code Online (Sandbox Code Playgroud) 我正在使用Java进行项目,我正在寻找开源库来解析快速消息:ISO 15022和20022。对于15022,我已经找到了一个解决方案,即Prowidesoftware,但对于20022,我没有找到任何东西。有任何想法吗?谢谢。