{"id":6708,"date":"2025-09-29T13:33:32","date_gmt":"2025-09-29T05:33:32","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=6708"},"modified":"2025-09-29T13:33:39","modified_gmt":"2025-09-29T05:33:39","slug":"springboot-%e6%96%b9%e6%b3%95%e7%ba%a7%e8%80%97%e6%97%b6%e7%9b%91%e6%8e%a7%e5%99%a8","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/springboot-%e6%96%b9%e6%b3%95%e7%ba%a7%e8%80%97%e6%97%b6%e7%9b%91%e6%8e%a7%e5%99%a8\/","title":{"rendered":"SpringBoot \u65b9\u6cd5\u7ea7\u8017\u65f6\u76d1\u63a7\u5668"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u4e00\u3001\u9700\u6c42\u75db\u70b9<\/h1>\n\n\n\n<p>\u7ebf\u4e0a\u5e94\u7528\u5e38\u89c1\u95ee\u9898\uff1a<\/p>\n\n\n\n<p>\u67d0\u4e9b\u63a5\u53e3\u5076\u5c14\u53d8\u6162\uff0c\u4f46\u65e5\u5fd7\u770b\u4e0d\u51fa\u95ee\u9898\uff1b<\/p>\n\n\n\n<p>\u65b9\u6cd5\u8c03\u7528\u6b21\u6570\u4e0d\u900f\u660e\uff0c\u6027\u80fd\u74f6\u9888\u96be\u627e\uff1b<\/p>\n\n\n\n<p>\u7ebf\u4e0a\u51fa\u73b0\u5931\u8d25\/\u8d85\u65f6\uff0c\u4f46\u7f3a\u4e4f\u7edf\u8ba1\u7ef4\u5ea6\uff1b<\/p>\n\n\n\n<p>\u60f3\u8981\u76d1\u63a7\uff0c\u5374\u4e0d\u60f3\u5f15\u5165\u91cd\u91cf\u7ea7\u7684 APM \u65b9\u6848\u3002<\/p>\n\n\n\n<p>\u5e38\u89c1 APM \u5de5\u5177\u529f\u80fd\u5f3a\u5927\uff0c\u4f46\u90e8\u7f72\u590d\u6742\u3001\u5b66\u4e60\u6210\u672c\u9ad8\uff0c\u4e0d\u9002\u5408\u4e2d\u5c0f\u56e2\u961f\u6216\u8005\u5355\u673a\u9879\u76ee\u3002<\/p>\n\n\n\n<p>\ud83d\udc49 \u90a3\u6709\u6ca1\u6709\u53ef\u80fd\uff0c\u57fa\u4e8e SpringBoot \u5b9e\u73b0\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u8017\u65f6\u76d1\u63a7\u5668\uff0c\u505a\u5230\u65b9\u6cd5\u7ea7\u76d1\u63a7 + \u53ef\u89c6\u5316\u7edf\u8ba1 \uff1f<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e8c\u3001\u529f\u80fd\u76ee\u6807<\/h1>\n\n\n\n<p>\u6211\u4eec\u5e0c\u671b\u76d1\u63a7\u5668\u80fd\u505a\u5230\uff1a<\/p>\n\n\n\n<p><strong>\u57fa\u7840\u76d1\u63a7\u80fd\u529b\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2022 \u65b9\u6cd5\u8c03\u7528\u6b21\u6570\uff1a\u7edf\u8ba1\u67d0\u65b9\u6cd5\u88ab\u8c03\u7528\u4e86\u591a\u5c11\u6b21<\/li>\n\n\n\n<li>\u2022 \u8017\u65f6\u6307\u6807\uff1a\u5e73\u5747\u8017\u65f6\u3001\u6700\u5927\u8017\u65f6\u3001\u6700\u5c0f\u8017\u65f6<\/li>\n\n\n\n<li>\u2022 \u6210\u529f\/\u5931\u8d25\u6b21\u6570\uff1a\u533a\u5206\u6b63\u5e38\u4e0e\u5f02\u5e38\u8c03\u7528<\/li>\n\n\n\n<li>\u2022 \u591a\u7ef4\u6392\u5e8f\uff1a\u652f\u6301\u6309\u8c03\u7528\u6b21\u6570\u3001\u5e73\u5747\u8017\u65f6\u3001\u5931\u8d25\u6b21\u6570\u7b49\u7ef4\u5ea6\u6392\u5e8f<\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fdb\u9636\u529f\u80fd\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2022 \u65f6\u95f4\u6bb5\u8fc7\u6ee4\uff1a\u9009\u62e9\u65f6\u95f4\u8303\u56f4\uff08\u5982\u6700\u8fd1 5 \u5206\u949f\u30011 \u5c0f\u65f6\u30011 \u5929\uff09\u67e5\u770b\u6570\u636e<\/li>\n\n\n\n<li>\u2022 \u63a5\u53e3\u641c\u7d22\uff1a\u5feb\u901f\u5b9a\u4f4d\u7279\u5b9a\u63a5\u53e3\u7684\u6027\u80fd\u6570\u636e<\/li>\n\n\n\n<li>\u2022 \u53ef\u89c6\u5316\u63a7\u5236\u53f0\uff1a\u5b9e\u65f6\u5c55\u793a\u63a5\u53e3\u8c03\u7528\u7edf\u8ba1<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e09\u3001\u6280\u672f\u8bbe\u8ba1<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">\u6574\u4f53\u601d\u8def<\/h3>\n\n\n\n<p><strong>\u65b9\u6cd5\u5207\u9762\u91c7\u96c6<\/strong><br>\u4f7f\u7528 SpringAOP\uff08\u57fa\u4e8e\u62e6\u622a\u5668\u4ea6\u53ef\uff09 \u62e6\u622a Controller \u65b9\u6cd5\uff0c\u5728\u65b9\u6cd5\u6267\u884c\u524d\u540e\u8bb0\u5f55\u65f6\u95f4\u5dee\u3001\u6267\u884c\u7ed3\u679c\uff08\u6210\u529f\/\u5931\u8d25\uff09\u3002<\/p>\n\n\n\n<p><strong>\u5206\u7ea7\u6570\u636e\u5b58\u50a8<\/strong><br>\u91c7\u7528\u5206\u7ea7\u65f6\u95f4\u6876\u7b56\u7565\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2022 \u6700\u8fd15\u5206\u949f\uff1a\u79d2\u7ea7\u7cbe\u5ea6\u7edf\u8ba1<\/li>\n\n\n\n<li>\u2022 \u6700\u8fd11\u5c0f\u65f6\uff1a\u5206\u949f\u7ea7\u805a\u5408<\/li>\n\n\n\n<li>\u2022 \u6700\u8fd124\u5c0f\u65f6\uff1a\u5c0f\u65f6\u7ea7\u805a\u5408<\/li>\n\n\n\n<li>\u2022 \u6700\u8fd17\u5929\uff1a\u5929\u7ea7\u805a\u5408<\/li>\n<\/ul>\n\n\n\n<p><strong>\u667a\u80fd\u67e5\u8be2<\/strong><br>\u6839\u636e\u67e5\u8be2\u65f6\u95f4\u8303\u56f4\uff0c\u81ea\u52a8\u9009\u62e9\u6700\u9002\u5408\u7684\u6570\u636e\u7c92\u5ea6\u8fdb\u884c\u805a\u5408\u8ba1\u7b97\u3002<\/p>\n\n\n\n<p><strong>\u63a5\u53e3\u5c55\u793a<\/strong><br>\u63d0\u4f9b REST API \u8f93\u51fa\u7edf\u8ba1\u6570\u636e\uff0c\u524d\u7aef\u4f7f\u7528 TailwindCSS + Alpine.js \u6e32\u67d3\u754c\u9762\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u56db\u3001\u6838\u5fc3\u5b9e\u73b0<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u65f6\u95f4\u6876\u6570\u636e\u6a21\u578b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@Data<br>publicclassTimeBucket&nbsp;{<br>&nbsp; &nbsp;&nbsp;privatefinalAtomicLongtotalCount=newAtomicLong(0);<br>&nbsp; &nbsp;&nbsp;privatefinalAtomicLongsuccessCount=newAtomicLong(0);<br>&nbsp; &nbsp;&nbsp;privatefinalAtomicLongfailCount=newAtomicLong(0);<br>&nbsp; &nbsp;&nbsp;privatefinalLongAddertotalTime=newLongAdder();<br>&nbsp; &nbsp;&nbsp;privatevolatilelongmaxTime=0;<br>&nbsp; &nbsp;&nbsp;privatevolatilelongminTime=&nbsp;Long.MAX_VALUE;<br>&nbsp; &nbsp;&nbsp;privatefinallong&nbsp;bucketStartTime;<br>&nbsp; &nbsp;&nbsp;privatevolatilelong&nbsp;lastUpdateTime;<br><br>&nbsp; &nbsp;&nbsp;publicTimeBucket(long&nbsp;bucketStartTime)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.bucketStartTime = bucketStartTime;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.lastUpdateTime = System.currentTimeMillis();<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;publicsynchronizedvoidrecord(long&nbsp;duration,&nbsp;boolean&nbsp;success)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; totalCount.incrementAndGet();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(success) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; successCount.incrementAndGet();<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; failCount.incrementAndGet();<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; totalTime.add(duration);<br>&nbsp; &nbsp; &nbsp; &nbsp; maxTime = Math.max(maxTime, duration);<br>&nbsp; &nbsp; &nbsp; &nbsp; minTime = Math.min(minTime, duration);<br>&nbsp; &nbsp; &nbsp; &nbsp; lastUpdateTime = System.currentTimeMillis();<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;publicdoublegetAvgTime()&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longtotal=&nbsp;totalCount.get();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;total ==&nbsp;0&nbsp;?&nbsp;0.0&nbsp;: (double) totalTime.sum() \/ total;<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;publicdoublegetSuccessRate()&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longtotal=&nbsp;totalCount.get();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;total ==&nbsp;0&nbsp;?&nbsp;0.0&nbsp;: (double) successCount.get() \/ total *&nbsp;100;<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5206\u7ea7\u91c7\u6837\u6307\u6807\u6a21\u578b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@Data<br>publicclassHierarchicalMethodMetrics&nbsp;{<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;\/\/ \u57fa\u7840\u7edf\u8ba1\u4fe1\u606f<br>&nbsp; &nbsp;&nbsp;privatefinalAtomicLongtotalCount=newAtomicLong(0);<br>&nbsp; &nbsp;&nbsp;privatefinalAtomicLongsuccessCount=newAtomicLong(0);<br>&nbsp; &nbsp;&nbsp;privatefinalAtomicLongfailCount=newAtomicLong(0);<br>&nbsp; &nbsp;&nbsp;privatefinalLongAddertotalTime=newLongAdder();<br>&nbsp; &nbsp;&nbsp;privatevolatilelongmaxTime=0;<br>&nbsp; &nbsp;&nbsp;privatevolatilelongminTime=&nbsp;Long.MAX_VALUE;<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;String methodName;<br><br>&nbsp; &nbsp;&nbsp;\/\/ \u5206\u7ea7\u65f6\u95f4\u6876<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;ConcurrentHashMap&lt;Long, TimeBucket&gt; secondBuckets =&nbsp;newConcurrentHashMap&lt;&gt;(); &nbsp;\/\/ \u6700\u8fd15\u5206\u949f\uff0c\u79d2\u7ea7<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;ConcurrentHashMap&lt;Long, TimeBucket&gt; minuteBuckets =&nbsp;newConcurrentHashMap&lt;&gt;(); &nbsp;\/\/ \u6700\u8fd11\u5c0f\u65f6\uff0c\u5206\u949f\u7ea7<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;ConcurrentHashMap&lt;Long, TimeBucket&gt; hourBuckets =&nbsp;newConcurrentHashMap&lt;&gt;(); &nbsp; &nbsp;\/\/ \u6700\u8fd124\u5c0f\u65f6\uff0c\u5c0f\u65f6\u7ea7<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;ConcurrentHashMap&lt;Long, TimeBucket&gt; dayBuckets =&nbsp;newConcurrentHashMap&lt;&gt;(); &nbsp; &nbsp;&nbsp;\/\/ \u6700\u8fd17\u5929\uff0c\u5929\u7ea7<br><br>&nbsp; &nbsp;&nbsp;publicsynchronizedvoidrecord(long&nbsp;duration,&nbsp;boolean&nbsp;success)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longcurrentTime=&nbsp;System.currentTimeMillis();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u66f4\u65b0\u57fa\u7840\u7edf\u8ba1<br>&nbsp; &nbsp; &nbsp; &nbsp; totalCount.incrementAndGet();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(success) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; successCount.incrementAndGet();<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; failCount.incrementAndGet();<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; totalTime.add(duration);<br>&nbsp; &nbsp; &nbsp; &nbsp; maxTime = Math.max(maxTime, duration);<br>&nbsp; &nbsp; &nbsp; &nbsp; minTime = Math.min(minTime, duration);<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u5206\u7ea7\u8bb0\u5f55\u5230\u4e0d\u540c\u65f6\u95f4\u6876<br>&nbsp; &nbsp; &nbsp; &nbsp; recordToTimeBuckets(currentTime, duration, success);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6e05\u7406\u8fc7\u671f\u6876<br>&nbsp; &nbsp; &nbsp; &nbsp; cleanupExpiredBuckets(currentTime);<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;public&nbsp;TimeRangeMetrics&nbsp;queryTimeRange(long&nbsp;startTime,&nbsp;long&nbsp;endTime)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; List&lt;TimeBucket.TimeBucketSnapshot&gt; buckets = selectBucketsForTimeRange(startTime, endTime);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;aggregateSnapshots(buckets, startTime, endTime);<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. AOP \u5207\u9762\u7edf\u8ba1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@Slf4j<br>@Aspect<br>@Component<br>publicclassMethodMetricsAspect&nbsp;{<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;ConcurrentHashMap&lt;String, HierarchicalMethodMetrics&gt; metricsMap =&nbsp;newConcurrentHashMap&lt;&gt;();<br><br>&nbsp; &nbsp;&nbsp;@Around(\"@within(org.springframework.web.bind.annotation.RestController) || \" +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"@within(org.springframework.stereotype.Controller)\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;Object&nbsp;recordMetrics(ProceedingJoinPoint joinPoint)throws&nbsp;Throwable {<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;StringmethodName=&nbsp;buildMethodName(joinPoint);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longstartTime=&nbsp;System.nanoTime();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;booleansuccess=true;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;Objectresult=&nbsp;joinPoint.proceed();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;result;<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(Throwable throwable) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success =&nbsp;false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;throw&nbsp;throwable;<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;finally&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longduration=&nbsp;(System.nanoTime() - startTime) \/&nbsp;1_000_000;&nbsp;\/\/ Convert to milliseconds<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; metricsMap.computeIfAbsent(methodName, HierarchicalMethodMetrics::new)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.record(duration, success);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;private&nbsp;String&nbsp;buildMethodName(ProceedingJoinPoint joinPoint)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;StringclassName=&nbsp;joinPoint.getTarget().getClass().getSimpleName();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;StringmethodName=&nbsp;joinPoint.getSignature().getName();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;className +&nbsp;\".\"&nbsp;+ methodName +&nbsp;\"()\";<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;public&nbsp;Map&lt;String, HierarchicalMethodMetrics&gt;&nbsp;getMetricsSnapshot()&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;returnnewConcurrentHashMap&lt;&gt;(metricsMap);<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u6570\u636e\u67e5\u8be2\u63a5\u53e3<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@RestController<br>@RequestMapping(\"\/api\/metrics\")<br>@RequiredArgsConstructor<br>publicclassMetricsController&nbsp;{<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;MethodMetricsAspect metricsAspect;<br><br>&nbsp; &nbsp;&nbsp;@GetMapping<br>&nbsp; &nbsp;&nbsp;public&nbsp;Map&lt;String, Object&gt;&nbsp;getMetrics(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;Long startTime,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;Long endTime,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;String methodFilter)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, Object&gt; result =&nbsp;newHashMap&lt;&gt;();<br>&nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, HierarchicalMethodMetrics&gt; snapshot = metricsAspect.getMetricsSnapshot();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u5e94\u7528\u63a5\u53e3\u540d\u8fc7\u6ee4<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(StringUtils.hasText(methodFilter)) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snapshot = snapshot.entrySet().stream()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .filter(entry -&gt; entry.getKey().toLowerCase().contains(methodFilter.toLowerCase()))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u65f6\u95f4\u8303\u56f4\u67e5\u8be2<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(startTime !=&nbsp;null&nbsp;&amp;&amp; endTime !=&nbsp;null) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snapshot.forEach((methodName, metrics) -&gt; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HierarchicalMethodMetrics.TimeRangeMetricstimeRangeMetrics=<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; metrics.queryTimeRange(startTime, endTime);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, Object&gt; metricData = buildTimeRangeMetricData(timeRangeMetrics);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.put(methodName, metricData);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u5168\u91cf\u6570\u636e<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snapshot.forEach((methodName, metrics) -&gt; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, Object&gt; metricData = buildMetricData(metrics);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.put(methodName, metricData);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;result;<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;@GetMapping(\"\/recent\/{minutes}\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;Map&lt;String, Object&gt;&nbsp;getRecentMetrics(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@PathVariable&nbsp;int&nbsp;minutes,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;String methodFilter)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longendTime=&nbsp;System.currentTimeMillis();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;longstartTime=&nbsp;endTime - (minutes *&nbsp;60L&nbsp;*&nbsp;1000L);<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;getMetrics(startTime, endTime, methodFilter);<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp;&nbsp;@GetMapping(\"\/summary\")<br>&nbsp; &nbsp;&nbsp;public&nbsp;Map&lt;String, Object&gt;&nbsp;getSummary(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;Long startTime,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;Long endTime,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;@RequestParam(required = false)&nbsp;String methodFilter)&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6c47\u603b\u7edf\u8ba1\u903b\u8f91<br>&nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, HierarchicalMethodMetrics&gt; snapshot = metricsAspect.getMetricsSnapshot();<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ ... \u6c47\u603b\u8ba1\u7b97<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;summary;<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u5b9a\u65f6\u6e05\u7406\u670d\u52a1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@Service<br>@RequiredArgsConstructor<br>publicclassMetricsCleanupService&nbsp;{<br><br>&nbsp; &nbsp;&nbsp;privatefinal&nbsp;MethodMetricsAspect metricsAspect;<br><br>&nbsp; &nbsp;&nbsp;@Value(\"${dashboard.metrics.max-age:3600000}\")<br>&nbsp; &nbsp;&nbsp;privatelong&nbsp;maxAge;<br><br>&nbsp; &nbsp;&nbsp;@Scheduled(fixedRateString = \"${dashboard.metrics.cleanup-interval:300000}\")<br>&nbsp; &nbsp;&nbsp;publicvoidcleanupStaleMetrics()&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; metricsAspect.removeStaleMetrics(maxAge);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;intcurrentMethodCount=&nbsp;metricsAspect.getMetricsSnapshot().size();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log.info(\"Metrics cleanup completed. Current methods being monitored: {}\", currentMethodCount);<br>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(Exception e) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log.error(\"Error during metrics cleanup\", e);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e94\u3001\u524d\u7aef\u53ef\u89c6\u5316\u754c\u9762<\/h1>\n\n\n\n<p>\u6838\u5fc3\u529f\u80fd\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function&nbsp;metricsApp() {<br>&nbsp; &nbsp;&nbsp;return&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;metrics: {},<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;summary: {},<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;timeRange:&nbsp;'all',<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;methodFilter:&nbsp;'',<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u65f6\u95f4\u8303\u56f4\u8bbe\u7f6e<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;setTimeRange(range) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.timeRange&nbsp;= range;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.updateTimeRangeText();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(range !==&nbsp;'custom') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.fetchMetrics();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.fetchSummary();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; },<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6784\u5efaAPI\u67e5\u8be2URL<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;buildApiUrl(endpoint) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;let&nbsp;url =&nbsp;`\/api\/metrics${endpoint}`;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;const&nbsp;params =&nbsp;newURLSearchParams();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6dfb\u52a0\u65f6\u95f4\u53c2\u6570<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(this.timeRange&nbsp;!==&nbsp;'all') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(this.timeRange&nbsp;===&nbsp;'custom') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(this.customStartTime&nbsp;&amp;&amp;&nbsp;this.customEndTime) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.append('startTime',&nbsp;newDate(this.customStartTime).getTime());<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.append('endTime',&nbsp;newDate(this.customEndTime).getTime());<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;const&nbsp;endTime =&nbsp;Date.now();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;const&nbsp;startTime = endTime - (this.timeRange&nbsp;*&nbsp;60&nbsp;*&nbsp;1000);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.append('startTime', startTime);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.append('endTime', endTime);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u6dfb\u52a0\u641c\u7d22\u53c2\u6570<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(this.methodFilter.trim()) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.append('methodFilter',&nbsp;this.methodFilter.trim());<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;params.toString() ? url +&nbsp;'?'&nbsp;+ params.toString() : url;<br>&nbsp; &nbsp; &nbsp; &nbsp; },<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\/\/ \u83b7\u53d6\u76d1\u63a7\u6570\u636e<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;asyncfetchMetrics() {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.loading&nbsp;=&nbsp;true;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;const&nbsp;response =&nbsp;awaitfetch(this.buildApiUrl(''));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.metrics&nbsp;=&nbsp;await&nbsp;response.json();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.lastUpdate&nbsp;=&nbsp;newDate().toLocaleTimeString();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;catch&nbsp;(error) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;console.error('Failed to fetch metrics:', error);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;finally&nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;this.loading&nbsp;=&nbsp;false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; };<br>}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u516d\u3001\u914d\u7f6e\u8bf4\u660e<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">application.yml \u914d\u7f6e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>server:<br>&nbsp;&nbsp;port:8080<br><br>spring:<br>application:<br>&nbsp; &nbsp;&nbsp;name:springboot-api-dashboard<br>aop:<br>&nbsp; &nbsp;&nbsp;auto:true<br>&nbsp; &nbsp;&nbsp;proxy-target-class:true<br><br># \u76d1\u63a7\u914d\u7f6e<br>dashboard:<br>metrics:<br>&nbsp; &nbsp;&nbsp;cleanup-interval:300000# \u6e05\u7406\u95f4\u9694\uff1a5\u5206\u949f<br>&nbsp; &nbsp;&nbsp;max-age:3600000&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# \u6700\u5927\u5b58\u6d3b\u65f6\u95f4\uff1a1\u5c0f\u65f6<br>&nbsp; &nbsp;&nbsp;debug-enabled:false&nbsp; &nbsp; &nbsp;# \u8c03\u8bd5\u6a21\u5f0f<br><br>logging:<br>level:<br>&nbsp; &nbsp;&nbsp;com.example.dashboard:&nbsp;INFO<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Maven \u4f9d\u8d56<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependencies&gt;<br>&nbsp; &nbsp;&nbsp;&lt;dependency&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;<br>&nbsp; &nbsp;&nbsp;&lt;\/dependency&gt;<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;&lt;dependency&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;artifactId&gt;spring-boot-starter-aop&lt;\/artifactId&gt;<br>&nbsp; &nbsp;&nbsp;&lt;\/dependency&gt;<br><br>&nbsp; &nbsp;&nbsp;&lt;dependency&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;groupId&gt;org.projectlombok&lt;\/groupId&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;artifactId&gt;lombok&lt;\/artifactId&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;optional&gt;true&lt;\/optional&gt;<br>&nbsp; &nbsp;&nbsp;&lt;\/dependency&gt;<br>&lt;\/dependencies&gt;<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e03\u3001\u4f7f\u7528\u793a\u4f8b<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">\u542f\u52a8\u5e94\u7528<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>mvn clean install<br>mvn spring-boot:run<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8bbf\u95ee\u754c\u9762<\/h3>\n\n\n\n<p>http:\/\/localhost:8080\/index.html<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"425\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-1024x425.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6709 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-1024x425.png 1024w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-300x124.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-768x319.png 768w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png 1080w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"425\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-1024x425.png\" alt=\"\" class=\"wp-image-6709\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-1024x425.png 1024w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-300x124.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-768x319.png 768w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png 1080w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/noscript><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">API \u8c03\u7528\u793a\u4f8b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u83b7\u53d6\u6240\u6709\u76d1\u63a7\u6570\u636e<br>curl http:\/\/localhost:8080\/api\/metrics<br><br># \u83b7\u53d6\u6700\u8fd15\u5206\u949f\u7684\u6570\u636e<br>curl http:\/\/localhost:8080\/api\/metrics\/recent\/5<br><br># \u6309\u65f6\u95f4\u8303\u56f4\u548c\u63a5\u53e3\u540d\u7b5b\u9009<br>curl&nbsp;\"http:\/\/localhost:8080\/api\/metrics?startTime=1640995200000&amp;endTime=1641000000000&amp;methodFilter=user\"<br><br># \u83b7\u53d6\u6c47\u603b\u7edf\u8ba1<br>curl http:\/\/localhost:8080\/api\/metrics\/summary<br><br># \u6e05\u7a7a\u76d1\u63a7\u6570\u636e<br>curl -X DELETE http:\/\/localhost:8080\/api\/metrics<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u516b\u3001\u5e94\u7528\u573a\u666f<\/h1>\n\n\n\n<p><strong>\u6027\u80fd\u5206\u6790<\/strong><br>\u5feb\u901f\u627e\u5230\u6700\u6162\u7684\u65b9\u6cd5\uff0c\u5b9a\u4f4d\u6027\u80fd\u74f6\u9888\uff1b<\/p>\n\n\n\n<p><strong>\u7a33\u5b9a\u6027\u76d1\u63a7<\/strong><br>\u53d1\u73b0\u5931\u8d25\u6b21\u6570\u591a\u7684\u63a5\u53e3\uff0c\u63d0\u524d\u9884\u8b66\uff1b<\/p>\n\n\n\n<p><strong>\u5bb9\u91cf\u8bc4\u4f30<\/strong><br>\u7edf\u8ba1\u9ad8\u9891\u8c03\u7528\u65b9\u6cd5\uff0c\u8f85\u52a9\u7cfb\u7edf\u6269\u5bb9\u51b3\u7b56\uff1b<\/p>\n\n\n\n<p><strong>\u95ee\u9898\u6392\u67e5<\/strong><br>\u7ed3\u5408\u65f6\u95f4\u6bb5\u7b5b\u9009\uff0c\u7cbe\u786e\u5b9a\u4f4d\u95ee\u9898\u53d1\u751f\u65f6\u95f4\uff1b<\/p>\n\n\n\n<p><strong>\u8d8b\u52bf\u5206\u6790<\/strong><br>\u901a\u8fc7\u4e0d\u540c\u65f6\u95f4\u7c92\u5ea6\u7684\u6570\u636e\uff0c\u5206\u6790\u63a5\u53e3\u6027\u80fd\u8d8b\u52bf\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e5d\u3001\u4f18\u52bf\u7279\u70b9<\/h1>\n\n\n\n<p><strong>\u8f7b\u91cf\u7ea7\u90e8\u7f72<\/strong><br>\u65e0\u9700\u5916\u90e8\u4f9d\u8d56\uff0c\u5355\u4e2a JAR \u5305\u5373\u53ef\u8fd0\u884c\uff1b<\/p>\n\n\n\n<p><strong>\u5373\u63d2\u5373\u7528<\/strong><br>\u6dfb\u52a0\u4f9d\u8d56\u540e\u81ea\u52a8\u542f\u7528\uff0c\u65e0\u9700\u590d\u6742\u914d\u7f6e\uff1b<\/p>\n\n\n\n<p><strong>\u8d44\u6e90\u53cb\u597d<\/strong><br>\u91c7\u7528\u5206\u7ea7\u91c7\u6837\u7b56\u7565\uff0c\u5185\u5b58\u5360\u7528\u53ef\u63a7\uff1b<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5341\u3001\u603b\u7ed3<\/h1>\n\n\n\n<p>\u901a\u8fc7 Spring Boot AOP + \u5206\u7ea7\u91c7\u6837 + \u73b0\u4ee3\u5316\u524d\u7aef\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684\u8f7b\u91cf\u7ea7 APM \u76d1\u63a7\u7cfb\u7edf\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2022 \u652f\u6301\u65b9\u6cd5\u7ea7\u76d1\u63a7\u548c\u65f6\u95f4\u6bb5\u7b5b\u9009<\/li>\n\n\n\n<li>\u2022 \u63d0\u4f9b\u76f4\u89c2\u7684\u53ef\u89c6\u5316\u754c\u9762\u548c\u641c\u7d22\u529f\u80fd<\/li>\n\n\n\n<li>\u2022 \u5177\u5907\u826f\u597d\u7684\u6027\u80fd\u8868\u73b0\u548c\u7a33\u5b9a\u6027<\/li>\n\n\n\n<li>\u2022 \u5f00\u7bb1\u5373\u7528\uff0c\u9002\u5408\u4e2d\u5c0f\u578b\u9879\u76ee\u5feb\u901f\u96c6\u6210<\/li>\n<\/ul>\n\n\n\n<p>\u5b83\u4e0d\u662f SkyWalking\u3001Pinpoint \u7684\u66ff\u4ee3\u54c1\uff0c\u4f46\u4f5c\u4e3a\u5355\u673a\u81ea\u7814\u7684\u5c0f\u578b APM \u89e3\u51b3\u65b9\u6848\uff0c\u5728\u7b80\u5355\u6027\u548c\u5b9e\u7528\u6027\u4e4b\u95f4\u53d6\u5f97\u4e86\u5f88\u597d\u7684\u5e73\u8861\u3002\u5bf9\u4e8e\u4e0d\u9700\u8981\u590d\u6742\u5206\u5e03\u5f0f\u8ffd\u8e2a\uff0c\u4f46\u5e0c\u671b\u6709\u57fa\u7840\u76d1\u63a7\u80fd\u529b\u7684\u9879\u76ee\u6765\u8bf4\uff0c\u8fd9\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002<\/p>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u9700\u6c42\u75db\u70b9 \u7ebf\u4e0a\u5e94\u7528\u5e38\u89c1\u95ee\u9898\uff1a \u67d0\u4e9b\u63a5\u53e3\u5076\u5c14\u53d8\u6162\uff0c\u4f46\u65e5\u5fd7\u770b\u4e0d\u51fa\u95ee\u9898\uff1b \u65b9\u6cd5\u8c03\u7528\u6b21\u6570\u4e0d\u900f\u660e\uff0c\u6027\u80fd\u74f6\u9888\u96be\u627e\uff1b \u7ebf\u4e0a\u51fa\u73b0\u5931\u8d25\/\u8d85\u65f6\uff0c\u4f46 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-6708","post","type-post","status-publish","format-standard","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556.png","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-1024x425.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929053327556-1024x425.png","id":"image1"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2025-09-29","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":179,"next_post_id":6711,"next_post_title":"Spring Boot \u5b9e\u73b0 SNMP \u5e94\u7528\u3001\u53d1\u9001\u4e0e\u89e3\u6790","previous_post_id":6688,"previous_post_title":"\u5f00\u6e90\u514d\u8d39\u3001\u7b80\u5355\u6613\u7528\u89c6\u9891\u8054\u52a8\u7269\u8054\u7f51\u5e73\u53f0\uff0c\u66f4\u9002\u5408\u4e2d\u5c0f\u4f01\u4e1a\u548c\u4e2a\u4eba\u5b66\u4e60\u4f7f\u7528","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=6708"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6708\/revisions"}],"predecessor-version":[{"id":6710,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6708\/revisions\/6710"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=6708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=6708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=6708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}