1.本地啟動項目開啟兩個啟動類出錯。
Error creating bean with name 'brokerService' defined in class path resource
[com/dfocus/meeting/framework/config/mq/ActiveMQConfig.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.apache.activemq.broker.BrokerService]:
Factory method 'brokerService' threw exception;
nested exception is java.io.IOException: Failed to bind to server socket:
tcp://localhost:61616 due to: java.net.BindException: Address already in use: JVM_Bind
由于項目使用了内置的ActiveMq,第一個啟動類啟動成功,内置ActiveMq也啟動了。啟動第二個啟動類時,ActiveMq正在啟動中,是以報錯。
2.解決方法
1.在第二個啟動類修改ActiveMq端口号,啟動一個新的内置ActiveMq。
2.使用外部部署的ActiveMq伺服器。