ibatis spring struts2 ,插入时,报空指针;更新时,不报错!何解???
packagetest.weibokeywordaccount;importorg.junit.Test;importorg.springframework.beans....
package test.weibokeywordaccount;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import ......
import ......[此处省略导入的包地址 ]
public class TestWeiboKeyWordAccount {
@Autowired
WeiboKeywordService service;
@Test
public void testInsertDiag(){
try{
WeiboKeyword key = new WeiboKeyword();
key.setId("2");
key.setKeyword("123");
key.setPlatform(5);
key.setStatusid("2");
service.idoInsert(key);
System.out.println("insert 成功!");
}catch (Exception e) {
e.printStackTrace();
}
}
}
异常信息:
java.lang.NullPointerException
at test.weibokeywordaccount.TestWeiboKeyWordAccount.testInsertDiag(TestWeiboKeyWordAccount.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 展开
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import ......
import ......[此处省略导入的包地址 ]
public class TestWeiboKeyWordAccount {
@Autowired
WeiboKeywordService service;
@Test
public void testInsertDiag(){
try{
WeiboKeyword key = new WeiboKeyword();
key.setId("2");
key.setKeyword("123");
key.setPlatform(5);
key.setStatusid("2");
service.idoInsert(key);
System.out.println("insert 成功!");
}catch (Exception e) {
e.printStackTrace();
}
}
}
异常信息:
java.lang.NullPointerException
at test.weibokeywordaccount.TestWeiboKeyWordAccount.testInsertDiag(TestWeiboKeyWordAccount.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询