{"id":3088,"date":"2023-08-30T14:29:19","date_gmt":"2023-08-30T06:29:19","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=3088"},"modified":"2023-08-30T14:29:20","modified_gmt":"2023-08-30T06:29:20","slug":"10%e4%b8%aa%e4%b8%8d%e5%8f%af%e4%b8%8d%e7%9f%a5%e7%9a%84spring-boot%e6%b3%a8%e9%87%8a%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/10%e4%b8%aa%e4%b8%8d%e5%8f%af%e4%b8%8d%e7%9f%a5%e7%9a%84spring-boot%e6%b3%a8%e9%87%8a%e6%96%b9%e6%b3%95\/","title":{"rendered":"10\u4e2a\u4e0d\u53ef\u4e0d\u77e5\u7684Spring Boot\u6ce8\u91ca\u65b9\u6cd5"},"content":{"rendered":"<section style=\"font-size: 16px; color: black; padding-right: 10px; padding-left: 10px; line-height: 1.6; letter-spacing: 0px; word-break: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<blockquote style=\"border-top: none; border-right: none; border-bottom: none; font-size: 0.9em; overflow: auto; color: #6a737d; padding: 10px 10px 10px 20px; margin-bottom: 20px; margin-top: 20px; border-left-color: #ef7060; background: #fff9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"font-size: 16px; padding-top: 8px; padding-bottom: 8px; color: black; line-height: 26px;\">\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd10\u4e2apring Boot\u6ce8\u91ca\u65b9\u6cd5\uff0c\u5e76\u9644\u6709\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u7406\u89e3\u3002<\/p>\n<\/blockquote>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"70%\" data-ratio=\"0.3314814814814815\" data-type=\"png\" data-w=\"1080\" data-data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"70%\" data-ratio=\"0.3314814814814815\" data-type=\"png\" data-w=\"1080\" data-data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" \/><noscript><img class=\"rich_pages wxw-img\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"70%\" data-ratio=\"0.3314814814814815\" data-type=\"png\" data-w=\"1080\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png\" \/><\/noscript><\/noscript><figcaption style=\"margin-top: 5px; text-align: center; color: #888; font-size: 14px;\">\u957f\u6309\u5173\u6ce8\u300aJava\u5b66\u7814\u5927\u672c\u8425\u300b<\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u672c\u6587\u4ecb\u7ecd\u60a8\u9700\u8981\u4e86\u89e3\u7684\u51e0\u4e2a\u57fa\u672c\u7684Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6ce8\u91ca\uff0c\u90fd\u9644\u6709\u8be6\u7ec6\u7684\u89e3\u91ca\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u60a8\u66f4\u597d\u7684\u7406\u89e3\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" data-ratio=\"0.7361111111111112\" data-type=\"png\" data-w=\"1080\" data-data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-05\/202308301420055d5d4cefd.png?wx_fmt=png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" \/><noscript><img class=\"rich_pages wxw-img\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" data-ratio=\"0.7361111111111112\" data-type=\"png\" data-w=\"1080\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-05\/202308301420055d5d4cefd.png?wx_fmt=png\" \/><\/noscript><\/figure>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">1 @SpringBootApplication<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u7c7b\u4e2d\u4f7f\u7528\u6b64\u6ce8\u91ca\u7528\u6765\u542f\u7528Spring Boot\u7684\u81ea\u52a8\u914d\u7f6e\u548c\u7ec4\u4ef6\u626b\u63cf\u7b49\u529f\u80fd\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">SpringBootApplication\u6ce8\u91ca\u7684\u4f5c\u7528\u662f\u4e0e\u4ee5\u4e0b\u6ce8\u91ca\u76f8\u7ed3\u5408\uff1a<\/p>\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">@EnableAutoConfiguration - \u542f\u7528Spring Boot\u7684\u81ea\u52a8\u914d\u7f6e\u529f\u80fd\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">@ComponentScan - \u542f\u7528\u7ec4\u4ef6\u626b\u63cf\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">@Configuration - \u542f\u7528\u57fa\u4e8eJava\u7684\u914d\u7f6e\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u793a\u4f8b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.boot.SpringApplication;\n<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.boot.autoconfigure.SpringBootApplication;\n\n<span style=\"color: #61aeee; line-height: 26px;\">@SpringBootApplication<\/span>\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">MyApplication<\/span>\u00a0<\/span>{\n\n\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"color: #c678dd; line-height: 26px;\">static<\/span>\u00a0<span style=\"color: #c678dd; line-height: 26px;\">void<\/span>\u00a0<span style=\"color: #61aeee; line-height: 26px;\">main<\/span><span style=\"line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{\n\u00a0\u00a0SpringApplication.run(MyApplication<span style=\"line-height: 26px;\">.<span style=\"color: #c678dd; line-height: 26px;\">class<\/span>,\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">args<\/span>)<\/span>;\n\u00a0}\n\n}\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">2 @Component<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5728\u7c7b\u7ea7\u522b\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u7528@Component\u6ce8\u91ca\u7684\u7c7b\u5c06\u88ab\u626b\u63cf\u4e3aSpring\u7ba1\u7406\u7684bean\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u7f16\u5199\u663e\u5f0f\u4ee3\u7801\u6765\u626b\u63cf\u521b\u5efa\u7684\u81ea\u5b9a\u4e49bean\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">Spring\u8fd8\u63d0\u4f9b\u4e863\u4e2a\u7279\u5b9a\u7684\u6784\u9020\u578b\u6ce8\u91ca\uff0c\u7528\u4e8e\u5c06\u7c7b\u4f5c\u4e3a\u7ec4\u4ef6 - Service\u3001Controller\u548cRepository\uff08\u5728\u540e\u9762\u7684\u90e8\u5206\u4e2d\u8ba8\u8bba\uff09<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u793a\u4f8b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.stereotype.Component;\n\n\n<span style=\"color: #61aeee; line-height: 26px;\">@Component<\/span>\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u903b\u8f91<\/span>\n}\u00a0\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">3 @Service<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u662f\u5c06\u7c7b\u6ce8\u91ca\u4e3a\u670d\u52a1\u5c42\uff0c\u8fd9\u610f\u5473\u7740\u8be5\u7c7b\u5c06\u4fdd\u5b58\u5e94\u7528\u7a0b\u5e8f\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u6ca1\u6709\u5176\u4ed6\u7528\u9014\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #61aeee; line-height: 26px;\">@Service<\/span>\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u4e1a\u52a1\u903b\u8f91<\/span>\n}\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">4 @Repository<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b83\u4e0e\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\u7684DAO(Data Access Object) \u5c42\u7684\u7c7b\u4e00\u8d77\u4f7f\u7528\uff0c\u6216\u8005\u4e0e\u5904\u7406\u6570\u636e\u5e93CRUD\u64cd\u4f5c\u7684repository\u7c7b\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #61aeee; line-height: 26px;\">@Repository<\/span>\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u6570\u636e\u5e93CRUD\u64cd\u4f5c<\/span>\n}\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">5 @Controller<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f7f\u7528@Controller\u6ce8\u91ca\u7684\u7c7b\u5c06\u5904\u7406\u6240\u6709\u7528\u6237\u8bf7\u6c42\u5e76\u8fd4\u56de\u9002\u5f53\u7684\u54cd\u5e94\u3002\u6b64\u6ce8\u91ca\u7528\u4e8eRestful Web\u670d\u52a1\u4ee5\u5904\u7406\u8bf7\u6c42\u548c\u54cd\u5e94\u3002<\/p>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">6 \u00a0@RequestMapping<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6b64\u6ce8\u91ca\u4e0e@Controller\u6ce8\u91ca\u4e00\u8d77\u4f7f\u7528\uff0c\u5c06HTTP\u8bf7\u6c42\u6620\u5c04\u5230\u9002\u5f53\u7684\u5904\u7406\u7a0b\u5e8f\u65b9\u6cd5\u3002\u8fd9\u53ef\u4ee5\u5728\u7c7b\u7ea7\u522b\u6216\u65b9\u6cd5\u7ea7\u522b\u4f7f\u7528\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">@Controller\u548c@RequestMapping\u7684\u793a\u4f8b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.stereotype.Controller;\n<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.web.bind.annotation.RequestMapping;\n\n\n<span style=\"color: #61aeee; line-height: 26px;\">@Controller<\/span>\n<span style=\"color: #61aeee; line-height: 26px;\">@RequestMapping<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"\/hello\"<\/span>)\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/HTTP\u00a0\u65b9\u6cd5<\/span>\n}\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">7 @Autowired<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">Autowired\u81ea\u52a8\u6ce8\u5165Spring\u7ba1\u7406\u7684\u7ec4\u4ef6\u4f9d\u8d56\u9879\uff0c\u7b80\u5355\u6765\u8bf4\uff0c\u5b83\u4e3a\u60a8\u521d\u59cb\u5316\u5bf9\u8c61\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #61aeee; line-height: 26px;\">@Controller<\/span>\n<span style=\"color: #61aeee; line-height: 26px;\">@RequestMapping<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"\/hello\"<\/span>)\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #61aeee; line-height: 26px;\">@Autowired<\/span>\u00a0\n\u00a0\u00a0\u00a0\u00a0HelloService\u00a0helloService;\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/HTTP\u00a0\u65b9\u6cd5<\/span>\n}\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">8 @Qualifier<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53Spring\u627e\u5230\u5177\u6709\u76f8\u540c\u7c7b\u578b\u7684\u591a\u4e2abean\u65f6\uff0c\u5904\u7406\u4f9d\u8d56\u9879\u6ce8\u5165\u65f6\u53ef\u80fd\u5b58\u5728\u6b67\u4e49\uff0c\u4f7f\u7528@Qualifier\u6ce8\u91ca\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u8981\u6ce8\u5165\u7684bean\u7684\u540d\u79f0\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #61aeee; line-height: 26px;\">@Controller<\/span>\n<span style=\"color: #61aeee; line-height: 26px;\">@RequestMapping<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"\/hello\"<\/span>)\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #61aeee; line-height: 26px;\">@Autowired<\/span>\u00a0\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #61aeee; line-height: 26px;\">@Qualifier<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"helloServiceBean\"<\/span>)\n\u00a0\u00a0\u00a0\u00a0HelloService\u00a0helloService;\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/HTTP\u00a0\u65b9\u6cd5<\/span>\n}\n<\/code><\/pre>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">9 @Bean<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u662f\u65b9\u6cd5\u7ea7\u522b\u7684\u6ce8\u91ca\uff0c\u7528\u4e8e\u5728Spring\u4e0a\u4e0b\u6587\u4e2d\u7ba1\u7406\u8fd4\u56de\u7684bean\u3002\u5b83\u901a\u5e38\u5728\u914d\u7f6e\u7c7b\u4e2d\u4f7f\u7528\u3002<\/p>\n<h2 style=\"margin-top: 30px; margin-bottom: 15px; font-weight: bold; border-bottom: 2px solid #ef7060; font-size: 1.3em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"display: inline-block; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">10 @Configuration<\/span><\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f7f\u7528@Configuration\u6ce8\u91ca\u7684\u7c7b\u8868\u793a\u8be5\u7c7b\u5c06\u7528\u4e8e\u58f0\u660e\u591a\u4e2a\u65b9\u6cd5\u4ee5\u8fd4\u56deSpring beans\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">@Configuration\u548c@Bean\u6ce8\u89e3\u7684\u793a\u4f8b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.context.annotation.Bean;\n<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0org.springframework.context.annotation.Configuration;\n\u00a0\n\n<span style=\"color: #61aeee; line-height: 26px;\">@Configuration<\/span>\n<span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">HelloWorld<\/span>\u00a0<\/span>{\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #61aeee; line-height: 26px;\">@Bean<\/span>\n\u00a0\u00a0\u00a0\u00a0<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">public<\/span>\u00a0HelloClass\u00a0<span style=\"color: #61aeee; line-height: 26px;\">collegeBean<\/span><span style=\"line-height: 26px;\">()<\/span>\n\u00a0\u00a0\u00a0\u00a0<\/span>{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">return<\/span>\u00a0<span style=\"color: #c678dd; line-height: 26px;\">new<\/span>\u00a0HelloClass();\n\u00a0\u00a0\u00a0\u00a0}\n}\n<\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u6bb5\u662fSpring\u6846\u67b6\u4e2d@Configuration\u548c@Bean\u6ce8\u89e3\u7684\u793a\u4f8b\u3002@Configuration\u6ce8\u89e3\u7528\u4e8e\u5c06\u4e00\u4e2a\u7c7b\u6807\u8bb0\u4e3a\u914d\u7f6e\u7c7b\uff0c\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u81ea\u52a8\u626b\u63cf\u548c\u7ba1\u7406\u3002@Bean\u6ce8\u89e3\u7528\u4e8e\u5c06\u4e00\u4e2a\u65b9\u6cd5\u6807\u8bb0\u4e3a\u751f\u4ea7bean\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e9b bean\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u88ab\u81ea\u52a8\u626b\u63cf\u548c\u7ba1\u7406\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u8fd9\u4e24\u4e2a\u6ce8\u89e3\u88ab\u4e00\u8d77\u4f7f\u7528\uff0c\u5c06HelloWorld\u7c7b\u6807\u8bb0\u4e3a\u914d\u7f6e\u7c7b\uff0c\u5e76\u5c06collegeBean()\u65b9\u6cd5\u6807\u8bb0\u4e3a\u751f\u4ea7bean\u7684\u65b9\u6cd5\uff0c\u4ee5\u4fbf\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u81ea\u52a8\u626b\u63cf\u548c\u7ba1\u7406\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"55%\" data-ratio=\"1.3399258343634117\" data-type=\"png\" data-w=\"809\" data-data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-06\/20230830142006ffffdbe6e.png?wx_fmt=png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" \/><noscript><img class=\"rich_pages wxw-img\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"55%\" data-ratio=\"1.3399258343634117\" data-type=\"png\" data-w=\"809\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-06\/20230830142006ffffdbe6e.png?wx_fmt=png\" \/><\/noscript><\/figure>\n<blockquote style=\"box-shadow: rgba(0, 0, 0, 0.2) 1px 1px 10px; padding: 20px; margin-bottom: 20px; margin-top: 20px; border: initial none initial;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<blockquote style=\"border: initial none initial;\">\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"70%\" data-ratio=\"0.3314814814814815\" data-type=\"png\" data-w=\"1080\" data-data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"70%\" data-ratio=\"0.3314814814814815\" data-type=\"png\" data-w=\"1080\" data-data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" \/><noscript><img class=\"rich_pages wxw-img\" style=\"display: block; margin-right: auto; margin-left: auto; height: auto !important;\" width=\"70%\" data-ratio=\"0.3314814814814815\" data-type=\"png\" data-w=\"1080\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png\" \/><\/noscript><\/noscript><\/figure>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><span style=\"color: initial; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; font-size: revert; letter-spacing: 0px; text-align: center;\">\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4f5c\u8005\uff1a\u539f\u521b \u5b66\u7814\u59b9 Java\u5b66\u7814\u5927\u672c\u8425 Java\u5b66\u7814\u5927\u672c\u8425 \u5fae\u4fe1\u53f7 java_study_camp \u529f\u80fd\u4ecb\u7ecd Java\u7f16\u7a0b\u3001\u540e\u7aef\u3001\u5927\u6570\u636e\u3001\u67b6\u6784\u5e08\u3001Spring\u3001Apache\u3001Linux\u5f00\u53d1 \u53d1\u8868\u4e8e<\/span><\/figure>\n<\/blockquote>\n<\/blockquote>\n<\/section>\n<p>\u8f6c\u8f7d\u5730\u5740\uff1ahttps:\/\/mp.weixin.qq.com\/s\/6C8MPtyXtsR9pk_uh8mlrA<\/p>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd10\u4e2apring Boot\u6ce8\u91ca\u65b9\u6cd5\uff0c\u5e76\u9644\u6709\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u7406\u89e3\u3002 \u957f\u6309\u5173\u6ce8\u300aJava\u5b66\u7814\u5927\u672c\u8425\u300b \u672c\u6587\u4ecb\u7ecd\u60a8\u9700\u8981\u4e86\u89e3\u7684 &#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-3088","post","type-post","status-publish","format-standard","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-05\/202308301420055d5d4cefd.png?wx_fmt=png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-05\/202308301420055d5d4cefd.png?wx_fmt=png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-06\/20230830142006ffffdbe6e.png?wx_fmt=png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-06\/20230830142006ffffdbe6e.png?wx_fmt=png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","id":"image7"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","id":"image8"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-08-30\/14-20-04\/2023083014200408088e23d.png?wx_fmt=png","id":"image9"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2023-08-30","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":371,"next_post_id":3092,"next_post_title":"\u4ee3\u7801\u7cbe\u7b8010\u500d\uff0c\u8d23\u4efb\u94fe\u6a21\u5f0fyyds","previous_post_id":3030,"previous_post_title":"Java\u540e\u53f0\u5b9e\u73b0\u7f51\u7ad9\u5fae\u4fe1\u626b\u7801\u767b\u5f55\u529f\u80fd\uff0c\u83b7\u53d6\u7528\u6237openid\uff0c\u53ca\u5fae\u4fe1\u7528\u6237\u4fe1\u606f\uff08\u5c0f\u7a0b\u5e8f\u7801\u65b9\u6848\uff09\uff0c\u5173\u8054\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff08\u4e2a\u4eba\u4e3b\u4f53\u5c0f\u7a0b\u5e8f\u4e5f\u53ef\u4ee5\uff09","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/3088","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=3088"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/3088\/revisions"}],"predecessor-version":[{"id":3096,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/3088\/revisions\/3096"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}