一个spring+mybatis工程,在工程中单独执行main方法没问题,可以正常调用,调用方式如下:
public static void genClassByTaskId(int taskId) {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();  
        context.setValidating(false);  
        context.load("classpath*:applicationContext*.xml");  
        context.refresh();
        IMockSCFServerService mockSCFService = context.getBean(MockSCFServiceImpl.class);
System.out.println(mockSCFService.selectMockServerByTaskId(taskId));
MockServerEntity mockServerEntity = mockSCFService.selectMockServerByTaskId(taskId);

但是打成jar包后,被外部工程调用上述方法时,就报
nException: No unique bean of type [com.qa.mockscftool.service.impl.MockSCF
ServiceImpl] is defined: expected single bean but found 0:
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
getBean(DefaultListableBeanFactory.java:269)
        at org.springframework.context.support.AbstractApplicationContext.getBea
n(AbstractApplicationContext.java:1083)
        at com.qa.mockscftool.ClassGenTools.genClassByTaskId(ClassGenTools.
java:31)
        at com.qa.mockscftool.ClassGenTools.main(ClassGenTools.java:154)
两天了,实在没找到问题所在的原因,求求各位大神帮忙解决了,谢谢了~