maven 打包junit单元测试报空指针 eclipse下正常
如下代码,在运行mvntest命令时,analysisResultService为空,报空指针异常,求解@RunWith(SpringJUnit4ClassRunner....
如下代码,在运行mvn test命令时,analysisResultService为空,报空指针异常,求解
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = {"classpath:applicationContext.xml","classpath:spring-mvc.xml"})
@Transactional
public class AnalysisResultServiceImplTest {
@Resource
private IAnalysisResultService analysisResultService;
@Test
@Rollback(false)
public void testGetAnalysisResultByTaskId() {
String taskid="0666b2c4-bf20-4a5b-9794-e1decabf8fce";
String analysisResult = analysisResultService.getAnalysisResultByTaskId(taskid);
System.out.println(analysisResult);
}
} 展开
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = {"classpath:applicationContext.xml","classpath:spring-mvc.xml"})
@Transactional
public class AnalysisResultServiceImplTest {
@Resource
private IAnalysisResultService analysisResultService;
@Test
@Rollback(false)
public void testGetAnalysisResultByTaskId() {
String taskid="0666b2c4-bf20-4a5b-9794-e1decabf8fce";
String analysisResult = analysisResultService.getAnalysisResultByTaskId(taskid);
System.out.println(analysisResult);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询