[Solved] rabbitMQ: factory.newConnection() Error: com.rabbitmq.client.ShutdownSignalException

About rabbitmq: factory Newconnection() reported an error com rabbitmq. client.ShutdownSignalException
exception information

Exception in thread "main" java.io.IOException
	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129)
	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125)
	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147)
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:439)
	at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:65)
	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:160)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1216)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1173)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1131)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1294)
	at util.ConnectionUtil.getConnection(ConnectionUtil.java:40)
	at Foundation_auto ACK.Send.main(Send.java:27)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - vhost /kavito not found, class-id=10, method-id=40)
	at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502)
	at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:293)
	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:141)
	... 9 more

tools

public class ConnectionUtil {
    private static final String HOST = "127.0.0.1";
    /**
     * Here java access requires the use of 5672;
     * web access uses 15672;
     */
    private static final Integer PORT = 5672;
    private static final String VIRTUAL_HOST = "/kavito";
    private static final String USERNAME = "chen";
    private static final String PASSWORD = "a123";

    public static Connection getConnection() throws IOException, TimeoutException {
        // Define the connection factory
        ConnectionFactory factory = new ConnectionFactory();
        // Service address
        factory.setHost(HOST);
        // Port
        factory.setPort(PORT);

        // set account information, username, password, vhost
        // set virtual machine, one mq service can set multiple virtual machines, each virtual machine is equivalent to a separate mq
        factory.setVirtualHost(VIRTUAL_HOST);
        factory.setUsername(USERNAME);
        factory.setPassword(PASSWORD);

        // Get the connection through the factory
        Connection connection = factory.newConnection();
        return connection;
    }
}

problem-solving: my solution is not to use the online setting permission

Reference commands for setting permissions
rabbitmqctl set_permissions -p "/" username ".*" ".*" ".*"

My problem is caused by setting the virtual machine
the default virtual machine on rabbitmq is


and the virtual machine set in my code is

Solution:
the first Change the virtual machine in the code to

the second Create a new virtual machine named/kavito in rabbitmq (PS: the name here depends on your actual situation)

and set permissions for the corresponding user

Read More: