0
我的英文不太好。先編碼。春季mvc服務費用調用方法太多時間
@ResponseBody
@RequestMapping(value = "testcall")
public UnifiedResponse testMethodCall(
HttpServletRequest request,
HttpServletResponse response) {
UnifiedResponse unifiedResponse = new UnifiedResponse();
logger.info("t1:"+System.currentTimeMillis());
Fun(0,1452,"abd",1);
logger.info("t2:"+System.currentTimeMillis());
userSignService.testcall();
logger.info("t3:"+System.currentTimeMillis());
return unifiedResponse;
}
String Fun(int i,long l,String s,int ii){
logger.info("f1:"+System.currentTimeMillis());
return "";
}
,日誌輸出:
t1:1393816077311
f1:1393816077312
t2:1393816077312
f2:1393816077345
t3:1393816077410
testcall()
是在服務的方法,既沒有參數也不返回值。只是輸出時間戳。
服務的實施是這樣的:
@Service
public class UserSignServiceImpl extends BaseServiceImpl implements IUserSignService {
public void testcall() {
logger.info("f1:"+System.currentTimeMillis());
}
}
實例通過註釋
@Autowired
IUserSignService userSignService;
這隻發生在某些服務器。在其他情況下,t3-t1小於2ms。所有服務器使用相同版本的JDK和Resin。
爲什麼?呼叫者和方法之間
堆棧跟蹤:
UserSignServiceImpl.testcall() line: 448
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: 319
ReflectiveMethodInvocation.invokeJoinpoint() line: 183
ReflectiveMethodInvocation.proceed() line: 150
TransactionInterceptor.invoke(MethodInvocation) line: 110
ReflectiveMethodInvocation.proceed() line: 172
ExposeInvocationInterceptor.invoke(MethodInvocation) line: 90
ReflectiveMethodInvocation.proceed() line: 172
JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 202
$Proxy49.testcall() line: not available
OtherController.testMethodCall(HttpServletRequest, HttpServletResponse) line: 6329
'userSignService'甚至來自哪裏? – Makoto
public interface IUserSignService;執行如下:@Service public class UserSignServiceImpl extends BaseServiceImpl implements IUserSignService – user3373353
公平的,但我不知道它在哪裏聲明或實例化。沒有這個,我們無法回答這個問題。 – Makoto