接着idea中运行,kafka,create topic, producer,consumer
配置kafka的应用application参数运行core包下的kafka主类
直接idea打开源码工程后,配置运行的应用设置。
配置Run/Debug Configurations
开启kafka应用 报错缺少包slf4j-nop:SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
缺少包slf4j-nop,导入该包。
具体步骤:
1 在dependencies.gradle中加入
slf4jnop: "org.slf4j:slf4j-nop:$versions.slf4j",2 在build.gradle中project(\':core\') 后面加上compile libs.slf4jnop
编译报错,没有有效错误消息FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task \':core:Kafka.main()\'.
Process \'command \'C:/Program Files/Java/jdk1.8.0_91/bin/java.exe\'\' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 42s
5 actionable tasks: 2 executed, 3 up-to-date
Disconnected from the target VM, address: \'127.0.0.1:20494\', transport: \'socket\'
20:37:10: Task execution finished \'Kafka.main()\'.
解决方案:
打开File->Settings->Build,Execution,Deployment->Build Tools->Gradle,将build&Run tests using改成InterlliJ IDEA。