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

来源:7-1 通用service

weixin_慕沐0534232

2021-12-14 23:36

@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回答

  • 霜花似雪
    2022-09-05 01:02:39
    @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);
    
    }


MyBatis-Plus入门

MyBatis-Plus框架入门必学课程!

56140 学习 · 381 问题

查看课程

相似问题