今天在学习Kafka整合Springboot项目的时候,往Kafka发送消息,消费者一直消费不到,ip地址,端口号,防火墙的状态都没有发现问题。后来发现是因为idea没有连接到虚拟机的,一直在找本机的ip地址,但我yml里面是配的虚拟机的ip地址,所以才连接不上去。后来发现更改server.properties里面的配置,重启之后就可以了。
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://xxx.xxx.xxx.xxx:9092
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://xxx.xxx.xxx.xxx:9092