{"id":1746,"date":"2025-09-03T16:47:45","date_gmt":"2025-09-03T08:47:45","guid":{"rendered":"https:\/\/zero-zl.cn\/?p=1746"},"modified":"2025-09-08T19:34:30","modified_gmt":"2025-09-08T11:34:30","slug":"03-springboot3%e6%a1%86%e6%9e%b6%e7%9a%84%e5%bf%ab%e9%80%9f%e6%90%ad%e5%bb%ba%e4%bb%a5%e5%8f%8a%e9%a1%b9%e7%9b%ae%e5%b7%a5%e7%a8%8b%e7%9a%84%e8%ae%b2%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/zero-zl.cn\/index.php\/2025\/09\/03\/03-springboot3%e6%a1%86%e6%9e%b6%e7%9a%84%e5%bf%ab%e9%80%9f%e6%90%ad%e5%bb%ba%e4%bb%a5%e5%8f%8a%e9%a1%b9%e7%9b%ae%e5%b7%a5%e7%a8%8b%e7%9a%84%e8%ae%b2%e8%a7%a3\/","title":{"rendered":"03. Springboot3\u6846\u67b6\u7684\u5feb\u901f\u642d\u5efa\u4ee5\u53ca\u9879\u76ee\u5de5\u7a0b\u7684\u8bb2\u89e3"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u7f16\u7a0b\u8f6f\u4ef6<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">IDEA2023\u4ee5\u4e0a\u3001Maven3.8\u3001JDK21<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u521b\u5efaSpring Boot\u5de5\u7a0b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b0\u5efa\u9879\u76ee<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-25.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"874\" height=\"790\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-25.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1750\" style=\"width:429px;height:auto\"  sizes=\"auto, (max-width: 874px) 100vw, 874px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5220\u9664\u65e0\u7528\u6587\u4ef6<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-26.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"509\" height=\"365\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-26.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1751\" style=\"width:428px;height:auto\"  sizes=\"auto, (max-width: 509px) 100vw, 509px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5220\u9664test\u76ee\u5f55<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5220\u9664resource\u91cc\u9762\u7684static\u548ctemplate\u6587\u4ef6\u5939<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7cbe\u7b80pom.xml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n    &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n    &lt;parent&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n        &lt;version&gt;3.5.5&lt;\/version&gt;\n        &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;\n    &lt;\/parent&gt;\n    &lt;groupId&gt;org.example&lt;\/groupId&gt;\n    &lt;artifactId&gt;springdemo&lt;\/artifactId&gt;\n    &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n    &lt;name&gt;springdemo&lt;\/name&gt;\n    &lt;description&gt;springdemo&lt;\/description&gt;\n\n    &lt;properties&gt;\n        &lt;java.version&gt;21&lt;\/java.version&gt;\n    &lt;\/properties&gt;\n    &lt;dependencies&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n            &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n        &lt;\/dependency&gt;\n\n\n    &lt;\/dependencies&gt;\n\n    &lt;build&gt;\n        &lt;plugins&gt;\n            &lt;plugin&gt;\n                &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n                &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\n            &lt;\/plugin&gt;\n        &lt;\/plugins&gt;\n    &lt;\/build&gt;\n\n&lt;\/project&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u9879\u76ee\u7ed3\u6784\u5206\u6790<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-28.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"300\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-28.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1753\" style=\"width:407px;height:auto\"  sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-27.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"330\" height=\"140\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-27.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1752\"  sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">target\uff1a\u662f\u6e90\u7801\u7f16\u8bd1\u540e\u7684\u6587\u4ef6<br>pom.xml\uff1a\u5b9a\u4e49Springbot\u7684\u6240\u6709\u4f9d\u8d56\u9879\uff0cspringboot\u52a0\u8f7d\u7684\u65f6\u5019\u4f1a\u626b\u63cf\u8fd9\u4e2a\u6587\u4ef6\u7684\u6240\u6709\u4f9d\u8d56\u9879<br><strong>SpringBoot\u91cc\u9762\u5185\u7f6e\u4e86Tomcat<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c06application.properties\u91cd\u547d\u540d\u4e3aapplication.yml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server:\n  port: 9999<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u542f\u52a8Spring Boot\u5de5\u7a0b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884cSpringdemoApplication.java\u542f\u52a8springboot\u5de5\u7a0b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5199\u4e00\u4e2a\u6d4b\u8bd5\u63a5\u53e3say\uff1ahello<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">controller\/WebController.java<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.springdemo.controller;\n\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\npublic class WebController {\n\n    \/\/\u8868\u793a\u8fd9\u662f\u4e00\u4e2aGet\u8bf7\u6c42\u7684\u63a5\u53e3\n    @GetMapping(\"\/hello\")       \/\/\u63a5\u53e3\u8def\u5f84,\u5168\u5c40\u552f\u4e00\n    public String hello() {\n        return \"Hello World!\";      \/\/\u63a5\u53e3\u7684\u8fd4\u56de\u503c\n    }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7edf\u4e00\u8fd4\u56de\u5305\u88c5\u7c7bResult<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5305\u88c5\u7c7b\uff1a\u4f5c\u7528\u662f\u7edf\u4e00\u540e\u7aef\u8fd4\u56de\u7684\u6570\u636e\u7c7b\u578b\uff0ccode\u662f\u4f5c\u4e3a\u524d\u7aef\u5224\u65ad\u8bf7\u6c42\u6210\u529f\u7684\u4e00\u53e5\uff0cmsg\u662f\u9519\u8bef\u4fe1\u606f\uff0cdata\u662f\u8fd4\u56de\u7ed9\u524d\u7aef\u7684\u6570\u636e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.springdemo.common;\n\npublic class Result {\n    private String code;\n    private Object data;\n    private String msg;\n\n    public static Result success(){\n        Result result = new Result();\n        result.setCode(\"200\");\n        result.setMsg(\"\u8bf7\u6c42\u6210\u529f\");\n        return result;\n    }\n\n    public static Result success(Object data){\n        Result result = new Result();\n        result.setCode(\"200\");\n        result.setData(data);\n        result.setMsg(\"\u8bf7\u6c42\u6210\u529f\");\n        return result;\n    }\n\n    public static Result error(String msg){\n        Result result = new Result();\n        result.setCode(\"500\");\n        result.setMsg(msg);\n        return result;\n    }\n\n    public static Result error(String code, String msg){\n        Result result = new Result();\n        result.setCode(code);\n        result.setMsg(msg);\n        return result;\n    }\n\n    public String getCode() {\n        return code;\n    }\n\n    public Object getData() {\n        return data;\n    }\n\n    public String getMsg() {\n        return msg;\n    }\n\n    public void setCode(String code) {\n        this.code = code;\n    }\n\n    public void setData(Object data) {\n        this.data = data;\n    }\n\n    public void setMsg(String msg) {\n        this.msg = msg;\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">500\u9519\u8bef\uff1a\u5e38\u89c1\u7684\u7cfb\u7edf\u7684\u9519\u8bef<\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-2.webp'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"308\" data-id=\"1760\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-2.webp\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1760\"  sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/div><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u629b\u51fa\u8fd9\u4e9b\u9519\u8bef\u975e\u5e38\u4e0d\u53cb\u597d\uff0c\u6211\u4eec\u5e94\u8be5\u4f7f\u7528\u7edf\u4e00\u7684\u5904\u7406\u65b9\u5f0f<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image.webp'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"200\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image.webp\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1759\"  sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-1-1024x230.webp'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"230\" data-original=\"https:\/\/zero-zl.cn\/wp-content\/uploads\/2025\/09\/image-1-1024x230.webp\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1761\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Ejipw\">\u5168\u5c40\u5f02\u5e38\u5904\u7406\u5668<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"u6a4bb0f3\">GlobalExceptionHandler<\/p>\n\n\n\n<pre id=\"jSYOM\" class=\"wp-block-code\"><code>package org.example.springdemo.exception;\n\nimport org.example.springdemo.common.Result;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.web.bind.annotation.ControllerAdvice;\nimport org.springframework.web.bind.annotation.ExceptionHandler;\nimport org.springframework.web.bind.annotation.ResponseBody;\n\n\n\/*\n* \u5168\u5c40\u5f02\u5e38\u6355\u83b7\u5668\n*\/\n@ControllerAdvice(\"org.example.springdemo.controller\")\npublic class GlobalExceptionHandler {\n    private static final Logger log= LoggerFactory.getLogger(GlobalExceptionHandler.class);\n\n    @ExceptionHandler(Exception.class)\n    @ResponseBody   \/\/\u5c06result\u5bf9\u8c61\u8f6c\u6362\u6210json\u7684\u683c\u5f0f\uff0c\u8fd4\u56de\u51fa\u6765\n    public Result error(Exception e){\n        log.error(\"\u7cfb\u7edf\u5f02\u5e38\", e);\n        return Result.error(\"\u7cfb\u7edf\u5f02\u5e38\");\n    }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"REa2L\">\u81ea\u5b9a\u4e49\u5f02\u5e38<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"u25ad0f2c\">CustomException<\/p>\n\n\n\n<pre id=\"u0dzn\" class=\"wp-block-code\"><code>package org.example.springdemo.exception;\n\n\/**\n * \u81ea\u5b9a\u4e49\u5f02\u5e38\u7c7b\n * \u8fd0\u884c\u65f6\u5f02\u5e38\n *\/\n\npublic class CustomerException extends RuntimeException{\n    private String code;\n    private String msg;\n\n    public CustomerException(String code, String msg) {\n        this.code = code;\n        this.msg = msg;\n    }\n\n    public CustomerException(String msg) {\n        this.code = \"500\";\n        this.msg = msg;\n    }\n\n    public CustomerException() {}\n\n    public String getCode() {\n        return code;\n    }\n\n    public String getMsg() {\n        return msg;\n    }\n\n    public void setCode(String code) {\n        this.code = code;\n    }\n\n    public void setMsg(String msg) {\n        this.msg = msg;\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"g4za7\">\u6700\u7ec8\u7248\u5168\u5c40\u5f02\u5e38<\/h2>\n\n\n\n<pre id=\"LFVzT\" class=\"wp-block-code\"><code>package org.example.springdemo.exception;\n\nimport org.example.springdemo.common.Result;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.web.bind.annotation.ControllerAdvice;\nimport org.springframework.web.bind.annotation.ExceptionHandler;\nimport org.springframework.web.bind.annotation.ResponseBody;\n\n\n\/*\n* \u5168\u5c40\u5f02\u5e38\u6355\u83b7\u5668\n*\/\n@ControllerAdvice(\"org.example.springdemo.controller\")\npublic class GlobalExceptionHandler {\n    private static final Logger log= LoggerFactory.getLogger(GlobalExceptionHandler.class);\n\n    @ExceptionHandler(Exception.class)\n    @ResponseBody   \/\/\u5c06result\u5bf9\u8c61\u8f6c\u6362\u6210json\u7684\u683c\u5f0f\uff0c\u8fd4\u56de\u51fa\u6765\n    public Result error(Exception e){\n        log.error(\"\u7cfb\u7edf\u5f02\u5e38\", e);\n        return Result.error(\"\u7cfb\u7edf\u5f02\u5e38\");\n    }\n\n    @ExceptionHandler(CustomerException.class)\n    @ResponseBody   \/\/\u5c06result\u5bf9\u8c61\u8f6c\u6362\u6210json\u7684\u683c\u5f0f\uff0c\u8fd4\u56de\u51fa\u6765\n    public Result customerError(CustomerException e){\n        log.error(\"\u81ea\u5b9a\u4e49\u9519\u8bef\", e);\n        return Result.error(e.getCode(),e.getMsg());\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7f16\u7a0b\u8f6f\u4ef6 IDEA2023\u4ee5\u4e0a\u3001Maven3.8\u3001JDK21 \u521b\u5efaSpring Boot\u5de5\u7a0b \u65b0\u5efa\u9879\u76ee \u5220\u9664\u65e0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114,102],"tags":[],"class_list":["post-1746","post","type-post","status-publish","format-standard","hentry","category-spring-boot3vue3","category-102"],"_links":{"self":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts\/1746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1746"}],"version-history":[{"count":4,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts\/1746\/revisions"}],"predecessor-version":[{"id":1762,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts\/1746\/revisions\/1762"}],"wp:attachment":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}