问题描述
在example.xsd文件中,我导入了一个看起来像这样的外部xsd文件:
select t.start_time + interval tally.n hour,count(*)
from t join
(select @rn := @rn + 1 as n
from t cross join
(select @rn := -1) params -- so it starts from 0
limit 100
) tally
on t.start_time + interval tally.n hour <= t.end_time
group by t.start_time + interval tally.n hour;
在配置文件中,我创建了XsdSchema和验证器bean
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.example.com"
xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd">
<import namespace="http://ws-i.org/profiles/basic/1.1/xsd" schemaLocation="http://ws-i.org/profiles/basic/1.1/swaref.xsd" />
<element name="attachment" type="wsi:swaRef" />
</schema>
启动服务器时,出现以下异常:
schema_reference:未能读取架构文档'swaref.xsd',因为由于accessExternalSchema属性设置的限制,不允许'http'访问。
为了解决该问题,我尝试了不同的操作,例如:
- 设置
@Bean public XsdSchema schema() { return new SimpleXsdSchema(new ClassPathResource("example.xsd")); } @Bean public XmlValidator schemaValidator(XsdSchema xsdSchema) { return xsdSchema.createValidator()); // throws exception }
- 设置
System.setProperty("javax.xml.accessExternalSchema","all");
- 在jdk / lib和jdk / jre / lib下创建jaxp.properties文件,并在其中添加
System.setProperty("javax.xml.accessExternalDTD","all");
- 将xsd中的导入更改为
javax.xml.accessExternalSchema = all
会导致不同的异常-无法将名称'wsi:swaRef'解析为一个(n)'类型定义'组件。
Java 11,Gradle 5.5.1,Spring Boot 2.1.6,jaxws-ri 2.3.2
如何使其正常工作?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)