你这个config的路径应该是在classpath的路径下的
如果是Spring项目resource资源路径下的配置文件,可以这样配置并获取bean。
// 运行spring配置文件
ApplicationContext content = new ClassPathXmlApplicationContext(
"/sdk-config/sdk-config.xml");
IFileOrZkFindServer zkService = (IFileOrZkFindServer) content
.getBean("FileOrZkFindServer");
config如果不确定,可以写绝对路径试试(更简单是放在resource下面).
junit测试类,加载spring文件是不是得在类上面加两个注解啊,
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public class TestMapperBase {
}