为了账号安全,请及时绑定邮箱和手机立即绑定

执行Bach()操作报空指针异常

@Test
public void Batch(){
    Displacementinfor displacementinfor = new Displacementinfor();
    displacementinfor.setEquipname("趋势GNSS高精定位仪");
    displacementinfor.setLongitude(102.123456f);

    Displacementinfor displacementinfor1 = new Displacementinfor();
    displacementinfor.setEquipname("大趋势");
    displacementinfor.setLongitude(34.123456f);

    List<Displacementinfor> displacementinfors = Arrays.asList(displacementinfor, displacementinfor1);
    boolean saveBatch = displacementinforService.saveBatch(displacementinfors);
    System.out.println(displacementinforService);

}

java.lang.NullPointerException

at com.laoyi.pandmonitor05.DisplacementinforInsertTest.Batch(DisplacementinforInsertTest.java:46)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)

at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)


正在回答

1 回答

@Test
public void Batch(){
    Displacementinfor displacementinfor = new Displacementinfor();
    displacementinfor.setEquipname("趋势GNSS高精定位仪");
    displacementinfor.setLongitude(102.123456f);

    Displacementinfor displacementinfor1 = new Displacementinfor();
    displacementinfor1.setEquipname("大趋势");
    displacementinfor1.setLongitude(34.123456f);

    List<Displacementinfor> displacementinfors = Arrays.asList(displacementinfor, displacementinfor1);
    boolean saveBatch = displacementinforService.saveBatch(displacementinfors);
    System.out.println(displacementinforService);

}


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

执行Bach()操作报空指针异常

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信