Unsupported major.minor version 52.0 错误

今天写ActiveMQ的时候,报错:Unsupported major.minor version 52.0

代码如下:

    // 61616 是activemq的端口
    private static final String url = "tcp://192.168.10.97:61616";
    private static final String mqName = "queue-test01";

    public static void getProduce() throws JMSException{
        // 创建一个ConnectionFactory    
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);

        //由connetionFactory创建一个connection
        Connection connection = connectionFactory.createConnection();

        // 启动连接
        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        Destination destination = session.createQueue(mqName);

        MessageProducer messageProducer = session.createProducer(destination);

        for (int i = 0; i < 100; i++) {
            TextMessage textMessage = session.createTextMessage("test" + i);
            messageProducer.send(textMessage);
            System.out.println("test" + i);
        }

        session.close();
    }

总结之后发现,这是一个版本的支持问题,一般来说是这样的:

  1. jdk版本低
  2. 你的jar包版本高

所以,我果断用了activemq-all-5.15.3.jar换成了apache-activemq-4.1.2.jar,解决问题。

你可能感兴趣的:(杂类,随笔)