看起来每个人都说正确的吸气剂:
例:
public class Test {
private boolean primitive;
private Boolean object;
public boolean isPrimitive() {
return primitive;
}
public Boolean getObject() {
return object;
}
//..
}
Run Code Online (Sandbox Code Playgroud)
题:
是否有任何规范或文档声明这是正确的,这是为布尔值指定getter的方法?或者这只是一个常见的假设?
我问becouse例如的wsimport生成的getter 是布尔对象.这是一个工具错误,还是这是允许的和正确的?
另一方面,一些framweork与这样的吸气剂不能正常工作.例如JSF(EL)或Dozer.
配置:
- Maven:3.0.5
- Java:1.6.0_45
描述:
假设我们有如下配置文件配置:
<profiles>
<profile>
<id>profile-1</id>
<activation>
<jdk>1.6</jdk>
<property>
<name>name</name>
<value>Hubert</value>
</property>
</activation>
</profile>
<profile>
<id>profile-2</id>
<activation>
<jdk>1.6</jdk>
<property>
<name>name</name>
<value>Wiktoria</value>
</property>
</activation>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
我们有两个配置文件:profile-1和profile-2.
当满足两个要求时,配置文件profile-1应该是活动的:
- jdk是版本1.6
- 属性名称具有值Hubert
题:
我们来看看这个配置:
mvn -Dname = Hubert help:active-profiles
结果我得到了两个活动的配置文件:profile-1和profile-2.
嗯...
配置文件profile-2不应该处于活动状态,因为属性名称的值与预期的Wiktoria不同.
有人可以解释一下为什么这样的工作?这是正常的行为吗?
谢谢.
Java:1.6
Woodstox:4.1.4
我正在尝试让Woodstox xml解析器成为我的朋友.但开始真的很难:)我有一个小?解析xml时遇到的问题如下:
<teams>
<team id="team1">Mom & Dad</team>
<team id="team2">Son & Daughter</team>
</teams>
Run Code Online (Sandbox Code Playgroud)
这很简单,但不幸的是我得到了这个例外:
Exception in thread "main" [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) (missing name?)
at [row,col {unknown-source}]: [2,24]
Run Code Online (Sandbox Code Playgroud)
这是因为角色和.
问题:
是否可以成功读取xml而不会出现此异常?
提前谢谢
休伯特
我在理解Context 时遇到问题。所以文档说Context是:
通过上下文协议在运算符等组件之间传播的键/值存储。上下文非常适合传输正交信息,例如跟踪或安全令牌。
伟大的。
现在让我们假设我们想使用Context传播一些东西,让它无处不在。要调用另一个异步代码,我们只需使用flatMap()方法。
问题:如何访问被调用方法内的上下文?
示例(简单)代码:
public class TestFlatMap {
public static void main(final String ...args) {
final Flux<String> greetings = Flux.just("Hubert", "Sharon")
.flatMap(TestFlatMap::nameToGreeting)
.subscriberContext(context ->
Context.of("greetingWord", "Hello") // context initialized
);
greetings.subscribe(System.out::println);
}
private static Mono<String> nameToGreeting(final String name) {
return Mono.just("Hello " + name + " !!!"); // ALERT: we don't have Context here
}
}
Run Code Online (Sandbox Code Playgroud)
被调用的方法可以(并且很可能会)在另一个类中。
提前感谢您的帮助!
编辑:删除了一些代码,使问题更加简洁明了。
JBoss:6或7
问题1:
Jboss创建了多少个消息驱动 Bean 实例来处理消息?
问题2:
如何配置JBoss创建的消息驱动 Bean 的数量?
假设我们有接口:
public interface IAuthentication { }
Run Code Online (Sandbox Code Playgroud)
和两个实现:
public class LdapAuthentication implements IAuthentication {}
public class DbAuthentication implements IAuthentication {}
Run Code Online (Sandbox Code Playgroud)
最后,我们有一个负责处理身份验证的 bean。这个 bean 应该使用上面显示的实现之一(基于例如 db 中指定的配置)。
@Service
public class AuthenticationService {
public boolean authenticate(...) {
boolean useDb = ...; //got from db
//my problem here
//how to get right implementation: either LdapAuthentication or DbAuthentication?
IAuthentication auth = ...;
return auth.authenticate(...);
}
}
Run Code Online (Sandbox Code Playgroud)
问题:
如何获得正确的实施?
如果开发人员未设置font-size,则默认值为medium
那么让我们来看看这个简单的代码:
<head>
<style type="text/css">
span .medium{
font-size: medium;
}
span .larger{
font-size: larger;
}
</style>
</head>
<body>
<span class="larger">Hello World!!!</span>
<span class="medium">Hello World!!!</span>
</body>
Run Code Online (Sandbox Code Playgroud)
结果是什么?两个字符串看起来完全一样.
为什么?
对值字体大小未指定为元件显式体,因此缺省值介质应该被使用.然后我们有两个跨度.第一个的font-size应该大于 body font-size.第二个的字体大小是绝对的,和body元素一样.所以第一个文本应该大于第二个文本.但事实并非如此.有谁可以向我解释一下?
提前致谢.
我想知道为什么生成(来自xsd)列表的getter始终为null检查:
public class Response {
@XmlElement(type = Integer.class)
protected List<Integer> integers;
public List<Integer> getIntegers() {
if (integers == null) {
integers = new ArrayList<Integer>();
}
return this.integers;
}
}
Run Code Online (Sandbox Code Playgroud)
题:
为什么?是什么原因?有什么好的吗?
我问在某些情况下,这不是一件好事.看起来没有办法改变这种行为.
Go版本:1.12.9
这是一个简单的演示项目的结构:
因此,我们有一个模块域,其中包含两个模块:activity和person。
我想将domain与主文件=> modules.go中的所有嵌套模块一起使用。
好的,我知道如何在主go.mod中导入域:
module modules
go 1.12
replace modules/domain v0.0.0 => ./domain
require modules/domain v0.0.0
Run Code Online (Sandbox Code Playgroud)
所以之后可以使用domain / domain.go中的代码,但是我无法访问!活动和人员模块中的代码。
是的,我可以手动导入嵌套模块,例如:
(main go.mod):
module modules
go 1.12
replace modules/domain v0.0.0 => ./domain
replace modules/domain/activity v0.0.0 => ./domain/activity
require (
modules/domain v0.0.0
modules/domain/activity v0.0.0
)
Run Code Online (Sandbox Code Playgroud)
但我不想手动导入所有子模块。
题:
如何配置模块以导入具有所有子模块的域?
预先感谢,
休伯特