在测试类的上方加入以下注解
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration("classpath:spring.xml")public class Test01 { @Autowired private AmqSenderService mapper; @Test public void test04() { // mapper.sendMsg(); }