这个问题已被各种各样的问题提出来 - 但我觉得仍然有进一步编目的空间.
我有一个带有两个元素定义的xsd
<xs:complexType name="elementA">
<xs:sequence>
<xs:element name="date" type="xs:string" minOccurs="0"/>
<xs:element name="lastXdigits" type="xs:string" nillable="true" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
这会产生:
protected String date;
@XmlElementRef(name = "lastXdigits", namespace = "http://xxxxxxx", type = JAXBElement.class)
protected JAXBElement<String> lastXDigits;
Run Code Online (Sandbox Code Playgroud)
将xsd更改为:
<xs:element name="lastXdigits" type="xs:string" nillable="true" minOccurs="1"/>
Run Code Online (Sandbox Code Playgroud)
结果是:
protected String date;
@XmlElement(name = "lastXdigits", required = true, nillable = true)
protected String lastXDigits;
Run Code Online (Sandbox Code Playgroud)
和使用:
<xs:element name="lastXdigits" type="xs:string" minOccurs="0"/>
Run Code Online (Sandbox Code Playgroud)
结果是:
protected String date;
@XmlElement(name = "lastXdigits")
protected String lastXDigits;
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎很奇怪.为什么在第一种情况下将lastXDigits生成为JAXBElement类型,为什么String类型在所有情况下都不够用?另外,当jaxb除了名称之外的定义相同时,为什么jaxb应该区别对待这两个元素呢?
我正在使用jaxb 2.0.5中的jaxb-xjc ant任务.
这看起来是否可疑或是否有充分的理由来解决这些差异?
我一直在网上寻找好几个小时,试图找到一种简单的方法来验证针对WSDL的完整SOAP消息.我知道有很多方法可以使用各种Web服务框架来实现这一点,但我不想这样做,因为要求只是验证一段XML.我可以验证模式,虽然我遇到的问题是有很多模式导入到WSDL中,我不知道应该验证哪一个模式.我可以编写一些实用程序来首先处理WSDL和响应以确定要对哪个XSD进行验证,但我认为这可以使用已建立的库作为单行程完成!
有没有人知道在给定WSDL和多个XSD的情况下验证XML文档的相对简单的方法?
我有一个长期运行的任务,我想完成,即使应用程序被推到后台.从文档中我可以看到,执行此操作的方法是使用beginBackgroundTaskWithExpirationHandler:功能并异步启动正在运行的任务,如以下代码段所示:
UIApplication* application = [UIApplicationsharedApplication];
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
// Clean up any unfinished task business by marking where you.
// stopped or ending the task outright.
[application endBackgroundTask: bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task, preferably in chunks.
for (int i = 0; i < 3; i++){
[self doChunkOfWork];
}
// end work
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
Run Code Online (Sandbox Code Playgroud)
现在我明白第二个代码块是异步执行的,一旦完成,应用程序就会被通知并且任务被标记为无效,但是,任何人都可以告诉我在什么情况下第一个代码块被执行以及第一个和第二个块如何获得相关?是不是因为我已经启动了一个任务,而且我接下来要做的就是调用dispatch_async这两个块会关联吗?
我已经在 Spring WebFlux 应用程序中设置了身份验证。身份验证机制似乎工作正常。例如,以下代码用于设置安全Web过滤器链:
@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
return http.authorizeExchange()
.pathMatchers("/path/to/resource").hasAuthority("A_ROLE")
.anyExchange().authenticated()
.and().httpBasic()
.and().build();
}
Run Code Online (Sandbox Code Playgroud)
这与 UserDetailsRepositoryReactiveAuthenticationManager 和 MapReactiveUserDetailsService 结合使用可以按预期工作。如果用户没有所需的权限,则会返回禁止的错误代码,否则请求将传递到处理程序。
我需要在处理程序本身内应用细粒度的权限检查,并认为我应该能够从请求中检索权限,如下所示:
public Mono<ServerResponse> getMyResource(ServerRequest serverRequest) {
Authentication authentication = (Authentication)serverRequest.principal().block();
...
}
Run Code Online (Sandbox Code Playgroud)
然而,我发现本金总是空的。首先,这是获取权限的正确方法吗?如果是,是否可能缺少一些上游配置?
有谁知道为什么Java编译器不允许以下操作的明确答案?
class BaseClass {
public <T extends Number> T getNumber(){
return null;
}
}
class SubClass extends BaseClass{
@Override
public <T extends Integer> T getNumber(){
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
这导致编译器抱怨:
“子类类型的方法getNumber()必须重写超类方法”
现在,当我将其提交给我的同事时,有些人试图解释说这将导致与编译器混淆。但是,正如还指出的,以下内容在概念上相似,是可以编辑的。
class BaseClass<T extends Number> {
public T getNumber(){
return null;
}
}
class SubClass<T extends Integer> extends BaseClass<T>{
@Override
public T getNumber(){
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
如果子类调用了super实现,则会被滥用,但是编译器会为此警告。我唯一的结论是,这是Sun公司人员的编译器监督(不能说Oracle:-S)。
有人对此有明确的答案吗?
我想知道是否有可能在同一个查询中加入相同的子选择,而不必再次执行查询?以下查询是我想要运行的实际混淆查询
select * from
(
-- Sub query A - same as sub query B
select bc.service_type, bc.cid, min(bc.last_modified_date) as last_modified1 from
(
select * from table_a bc2
where bc2.state != 7
AND bc2.cid in
(
select cid from table_a TA, table_b TB
where TB.name not like '% IS' and TA.state != 7
AND TA.service_type = 1
AND TA.username is not null
and TA.bctid = TB.bctid
)
) bc
group by service_type, cid
) result1,
(
// Sub query B …Run Code Online (Sandbox Code Playgroud)