- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我以前用过这个,所以我不知道为什么它不起作用。考虑这段代码
public class NioServer implements Runnable {
private EventLoopGroup group;
private ServerBootstrap b;
public static final AttributeKey<Session> SESSION_KEY = new AttributeKey<>("SessionHandler.attr");
@Override
public void run() {
group = new NioEventLoopGroup();
b = new ServerBootstrap();
b.group(group)
.channel(NioServerSocketChannel.class)
.localAddress(435)
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childOption(ChannelOption.TCP_NODELAY, true)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("Session Handler", new SessionHandler());
}
});
}
}
AttributeKey SESSION_KEY 不想工作并给出错误:
"cannot infer type arguments for AttributeKey<> reason: cannot infer type-variable(s) T (actual and formal argument lists differ in length) where T is a type-variable: T extends Object declared in class AttributeKey"
我不明白...我错过了什么吗?没有与此相关的其他问题,但是其他问题确实以这种方式成功使用了 AttributeKey。
规范:
更新:
好吧,我已将版本降级为 4.0.21 Final
显然AttributeKey<>("")
已弃用,但我找不到任何进一步的信息。任何人都知道 4.1.0
中的替代品/替代品版本?它适用于 4.0.21 Final
顺便说一下。
最佳答案
好吧。引用用户“Mics”:
Short answer: There's no AttributeKey(String) in netty 4.1, use AttributeKey.valueOf(String). Additional information: github.com/netty/netty/issues/1824
感谢您的回答。
关于java - Netty AttributeKey - 无法推断 AttributeKey<> 的类型参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25190200/
我以前用过这个,所以我不知道为什么它不起作用。考虑这段代码 public class NioServer implements Runnable { private EventLoopGrou
属性键已贬值并导致我的代码出现问题。我查看了 netty wiki,它说我应该“使用 valueOf(String) 代替”。嗯,我不明白查找字符串的值与属性键有什么关系。有人对此有一些解释吗? 最佳
运行 GreetingServerTest.java 测试后,我遇到了以下错误。我正在使用 grpc 1.1.0-SNAPSHOT 库并尝试实现 git repo 中给出的 grpc 的基本 Hell
我是一名优秀的程序员,十分优秀!