我将json发布到我的kafka主题之一:
{
"hash": "ABC",
"height": 107900,
"time": 1297626305,
"txs": [
{
"hash": "XYZ1",
"index": 0,
"version": 1,
"inputs": [
{
"prevout": {
"hash": "IN1",
"index": 4294967295
},
"script": "045285021b0173",
"address": null
}
],
"outputs": [
{
"value": 5001000000,
"address": "OUT1"
}
],
"locktime": 0
},
{
"hash": "XYZ2",
"index": 1,
"version": 1,
"inputs": [
{
"prevout": {
"hash": "IN12",
"index": 1
},
"coin": {
"version": 1,
"height": 107899,
"value": 34645000000,
"address": "IN2",
"coinbase": false
}
}
],
"outputs": [
{
"value": 6000000,
"address": "OUT2"
},
{
"value": 70000000,
"address": "OUT4"
}
],
"locktime": 0
}
]
}
我想要得到像这样的结果:
{
address: IN2
result : {
output : OUT2,
value: 6000000
},
result : {
output : OUT4,
value: 70000000
},
我正在尝试使用帖子Parsing JSON data using Apache Kafka Streaming中给出的相同方法,但出现以下错误:
我正在尝试创建不同的POJO,并尝试使用上述参考答案中提供的解决方案。但出现错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/kafka/common/serialization/Deserializer
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException:
org.apache.kafka.common.serialization.Deserializer
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
我尝试在运行java -cp时将此类添加到classpath 但是,一旦我为这个jar添加,其他的jar就会出现错误。 然后这样下去.. :( 请提供解决方案。
谢谢。