{"id":42079,"date":"2025-06-06T11:15:41","date_gmt":"2025-06-06T03:15:41","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/42079.html"},"modified":"2025-06-06T11:15:41","modified_gmt":"2025-06-06T03:15:41","slug":"spring-boot-%e5%86%85%e5%b5%8c%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/42079.html","title":{"rendered":"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668"},"content":{"rendered":"<h4>Spring Boot \u5185\u5d4c\u670d\u52a1\u5668\u5168\u9762\u89e3\u6790<\/h4>\n<p>Spring Boot \u662f\u76ee\u524d\u6700\u6d41\u884c\u7684 Java \u540e\u7aef\u6846\u67b6\u4e4b\u4e00&#xff0c;\u5176\u5185\u5d4c\u670d\u52a1\u5668\u7279\u6027\u4f7f\u5f97\u5f00\u53d1\u8005\u65e0\u9700\u5355\u72ec\u90e8\u7f72\u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u5927\u5927\u7b80\u5316\u4e86\u9879\u76ee\u7684\u5f00\u53d1\u548c\u90e8\u7f72\u6d41\u7a0b\u3002\u5728 Spring Boot \u4e2d&#xff0c;\u5e94\u7528\u7a0b\u5e8f\u81ea\u5e26\u4e00\u4e2a\u5185\u5d4c\u7684 Web \u670d\u52a1\u5668&#xff0c;\u5982 Tomcat\u3001Jetty \u6216 Undertow&#xff0c;\u8fd9\u4e3a\u5f00\u53d1\u548c\u8fd0\u884c\u5fae\u670d\u52a1\u63d0\u4f9b\u4e86\u6781\u5927\u7684\u4fbf\u5229\u3002<\/p>\n<hr \/>\n<h4>\u4e00\u3001\u4ec0\u4e48\u662f Spring Boot \u5185\u5d4c\u670d\u52a1\u5668&#xff1f;<\/h4>\n<p>Spring Boot \u7684\u5185\u5d4c\u670d\u52a1\u5668&#xff08;Embedded Server&#xff09;\u662f\u4e00\u79cd\u5c06 Web \u670d\u52a1\u5668\u76f4\u63a5\u6253\u5305\u5230\u5e94\u7528\u4e2d\u7684\u6280\u672f\u3002\u4e0e\u4f20\u7edf Java Web \u5e94\u7528\u4e0d\u540c&#xff0c;Spring Boot \u5e94\u7528\u4e0d\u9700\u8981\u5728\u5916\u90e8\u5e94\u7528\u670d\u52a1\u5668&#xff08;\u5982 Apache Tomcat \u6216 JBoss&#xff09;\u4e2d\u90e8\u7f72&#xff0c;\u800c\u662f\u901a\u8fc7\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u8fd0\u884c JAR \u6587\u4ef6\u542f\u52a8\u81ea\u5df1\u7684\u5185\u5d4c\u670d\u52a1\u5668\u3002<\/p>\n<p>\u7279\u70b9&#xff1a;<\/p>\n<li>\u72ec\u7acb\u8fd0\u884c&#xff1a;\u65e0\u9700\u4f9d\u8d56\u5916\u90e8\u670d\u52a1\u5668&#xff0c;\u76f4\u63a5\u8fd0\u884c JAR \u6587\u4ef6\u5373\u53ef\u3002<\/li>\n<li>\u7075\u6d3b\u6027&#xff1a;\u652f\u6301\u591a\u79cd\u5185\u5d4c\u670d\u52a1\u5668&#xff08;\u5982 Tomcat\u3001Jetty\u3001Undertow&#xff09;\u3002<\/li>\n<li>\u6613\u4e8e\u914d\u7f6e&#xff1a;\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8f7b\u677e\u8c03\u6574\u670d\u52a1\u5668\u53c2\u6570\u3002<\/li>\n<li>\u9002\u5408\u5fae\u670d\u52a1&#xff1a;\u7b80\u5316\u5fae\u670d\u52a1\u7684\u90e8\u7f72\u6d41\u7a0b&#xff0c;\u652f\u6301\u5bb9\u5668\u5316\u3002<\/li>\n<hr \/>\n<h4>\u4e8c\u3001Spring Boot \u5185\u5d4c\u670d\u52a1\u5668\u7684\u9ed8\u8ba4\u884c\u4e3a<\/h4>\n<p>Spring Boot \u9ed8\u8ba4\u4f7f\u7528 Tomcat \u4f5c\u4e3a\u5185\u5d4c\u670d\u52a1\u5668&#xff0c;\u5e76\u5728\u542f\u52a8\u65f6\u81ea\u52a8\u52a0\u8f7d\u76f8\u5173\u914d\u7f6e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684 Spring Boot \u5e94\u7528\u7a0b\u5e8f\u793a\u4f8b&#xff1a;<\/p>\n<p>\u793a\u4f8b&#xff1a;\u9ed8\u8ba4\u5185\u5d4c\u670d\u52a1\u5668\u542f\u52a8<\/p>\n<p><span class=\"token annotation punctuation\">&#064;SpringBootApplication<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">EmbeddedServerDemoApplication<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> args<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">SpringApplication<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">EmbeddedServerDemoApplication<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">,<\/span> args<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd0\u884c\u4e0a\u8ff0\u7a0b\u5e8f\u540e&#xff0c;\u63a7\u5236\u53f0\u4f1a\u663e\u793a\u5982\u4e0b\u8f93\u51fa&#xff0c;\u8868\u793a Tomcat \u5185\u5d4c\u670d\u52a1\u5668\u5df2\u542f\u52a8&#xff1a;<\/p>\n<p>Tomcat started on port(s): 8080 (http) with context path &#039;&#039;<\/p>\n<hr \/>\n<h4>\u4e09\u3001\u66f4\u6362\u5185\u5d4c\u670d\u52a1\u5668<\/h4>\n<p>Spring Boot \u9ed8\u8ba4\u4f7f\u7528 Tomcat&#xff0c;\u4f46\u4e5f\u652f\u6301 Jetty \u548c Undertow\u3002\u53ef\u4ee5\u901a\u8fc7\u66ff\u6362\u4f9d\u8d56\u8f7b\u677e\u66f4\u6539\u5185\u5d4c\u670d\u52a1\u5668\u3002<\/p>\n<h5>3.1 \u4f7f\u7528 Jetty<\/h5>\n<p>\u6b65\u9aa4&#xff1a;<\/p>\n<li>\n<p>\u5728 pom.xml \u4e2d\u5220\u9664 Tomcat \u4f9d\u8d56&#xff1a;<\/p>\n<p> <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>org.springframework.boot<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>spring-boot-starter-tomcat<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>scope<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>provided<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>scope<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\n <\/li>\n<li>\n<p>\u6dfb\u52a0 Jetty \u4f9d\u8d56&#xff1a;<\/p>\n<p> <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>org.springframework.boot<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>spring-boot-starter-jetty<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\n <\/li>\n<p>\u8fd0\u884c\u5e94\u7528\u540e&#xff0c;\u63a7\u5236\u53f0\u8f93\u51fa\u5c06\u663e\u793a Jetty \u5df2\u542f\u52a8&#xff1a;<\/p>\n<p>Jetty started on port(s): 8080 (http) with context path &#039;&#039;<\/p>\n<hr \/>\n<h5>3.2 \u4f7f\u7528 Undertow<\/h5>\n<p>\u6b65\u9aa4&#xff1a;<\/p>\n<li>\u5728 pom.xml \u4e2d\u5220\u9664 Tomcat \u4f9d\u8d56\u3002<\/li>\n<li>\u6dfb\u52a0 Undertow \u4f9d\u8d56&#xff1a;<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>org.springframework.boot<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>groupId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>spring-boot-starter-undertow<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>artifactId<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>dependency<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\n <\/li>\n<p>\u8fd0\u884c\u540e&#xff0c;\u63a7\u5236\u53f0\u4f1a\u663e\u793a Undertow \u542f\u52a8\u65e5\u5fd7\u3002<\/p>\n<hr \/>\n<h4>\u56db\u3001\u5185\u5d4c\u670d\u52a1\u5668\u7684\u5e38\u89c1\u914d\u7f6e<\/h4>\n<p>Spring Boot \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u5f0f\u6765\u914d\u7f6e\u5185\u5d4c\u670d\u52a1\u5668&#xff0c;\u5305\u62ec application.properties \u6587\u4ef6\u548c Java \u4ee3\u7801\u3002<\/p>\n<h5>4.1 \u914d\u7f6e\u7aef\u53e3<\/h5>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;Spring Boot \u7684\u5185\u5d4c\u670d\u52a1\u5668\u8fd0\u884c\u5728 8080 \u7aef\u53e3\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u4fee\u6539\u7aef\u53e3&#xff1a;<\/p>\n<p>\u65b9\u6cd5 1&#xff1a;\u5728 application.properties \u4e2d\u914d\u7f6e<\/p>\n<p>server.port&#061;9090<\/p>\n<p>\u65b9\u6cd5 2&#xff1a;\u4f7f\u7528 Java \u4ee3\u7801\u914d\u7f6e<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Bean<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token class-name\">WebServerFactoryCustomizer<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">ConfigurableWebServerFactory<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">webServerFactoryCustomizer<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> factory <span class=\"token operator\">-&gt;<\/span> factory<span class=\"token punctuation\">.<\/span><span class=\"token function\">setPort<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">9090<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h5>4.2 \u914d\u7f6e\u4e0a\u4e0b\u6587\u8def\u5f84<\/h5>\n<p>\u4e0a\u4e0b\u6587\u8def\u5f84\u662f\u670d\u52a1\u5668\u4e2d\u5e94\u7528\u7a0b\u5e8f\u7684\u8bbf\u95ee\u8def\u5f84\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;Spring Boot \u4f7f\u7528\u6839\u8def\u5f84 &#034;\/&#034;\u3002<\/p>\n<p>\u4fee\u6539\u4e0a\u4e0b\u6587\u8def\u5f84<\/p>\n<p>server.servlet.context-path&#061;\/myapp<\/p>\n<p>\u542f\u52a8\u540e&#xff0c;\u5e94\u7528\u5c06\u901a\u8fc7 http:\/\/localhost:8080\/myapp \u8bbf\u95ee\u3002<\/p>\n<hr \/>\n<h5>4.3 \u914d\u7f6e\u6700\u5927\u7ebf\u7a0b\u6570<\/h5>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8c03\u6574\u670d\u52a1\u5668\u7ebf\u7a0b\u6c60\u7684\u6700\u5927\u7ebf\u7a0b\u6570&#xff0c;\u4ee5\u63d0\u5347\u5e76\u53d1\u5904\u7406\u80fd\u529b&#xff1a;<\/p>\n<p>server.tomcat.threads.max&#061;200<\/p>\n<p>\u6216\u4f7f\u7528 Java \u914d\u7f6e&#xff1a;<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Bean<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token class-name\">WebServerFactoryCustomizer<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">TomcatServletWebServerFactory<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">customizer<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> factory <span class=\"token operator\">-&gt;<\/span> factory<span class=\"token punctuation\">.<\/span><span class=\"token function\">addConnectorCustomizers<\/span><span class=\"token punctuation\">(<\/span>connector <span class=\"token operator\">-&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        connector<span class=\"token punctuation\">.<\/span><span class=\"token function\">setAttribute<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;maxThreads&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">200<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h5>4.4 \u914d\u7f6e SSL<\/h5>\n<p>\u4e3a\u5185\u5d4c\u670d\u52a1\u5668\u542f\u7528 HTTPS&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b8c\u6210&#xff1a;<\/p>\n<li>\n<p>\u5728 application.properties \u4e2d\u542f\u7528 SSL&#xff1a;<\/p>\n<p> server.ssl.enabled&#061;true<br \/>\nserver.ssl.key-store&#061;classpath:keystore.p12<br \/>\nserver.ssl.key-store-password&#061;password<br \/>\nserver.ssl.key-store-type&#061;PKCS12\n <\/li>\n<li>\n<p>\u63d0\u4f9b\u4e00\u4e2a\u6709\u6548\u7684 SSL \u5bc6\u94a5\u5e93\u6587\u4ef6&#xff08;keystore.p12&#xff09;\u3002<\/p>\n<\/li>\n<hr \/>\n<h4>\u4e94\u3001\u7981\u7528\u5185\u5d4c\u670d\u52a1\u5668<\/h4>\n<p>\u5728\u67d0\u4e9b\u573a\u666f\u4e2d&#xff08;\u5982\u4ec5\u5f00\u53d1 REST \u5ba2\u6237\u7aef\u5e94\u7528&#xff09;&#xff0c;\u53ef\u4ee5\u7981\u7528\u5185\u5d4c\u670d\u52a1\u5668\u3002<\/p>\n<h5>\u65b9\u6cd5&#xff1a;\u5c06 web \u73af\u5883\u8bbe\u7f6e\u4e3a NONE<\/h5>\n<p><span class=\"token annotation punctuation\">&#064;SpringBootApplication<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">NonWebApplication<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> args<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">SpringApplication<\/span> app <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">SpringApplication<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">NonWebApplication<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        app<span class=\"token punctuation\">.<\/span><span class=\"token function\">setWebApplicationType<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">WebApplicationType<\/span><span class=\"token punctuation\">.<\/span><span class=\"token constant\">NONE<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        app<span class=\"token punctuation\">.<\/span><span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span>args<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h4>\u516d\u3001\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848<\/h4>\n<h5>6.1 \u7aef\u53e3\u51b2\u7a81<\/h5>\n<p>\u95ee\u9898&#xff1a; \u5185\u5d4c\u670d\u52a1\u5668\u542f\u52a8\u65f6&#xff0c;\u7aef\u53e3\u88ab\u5176\u4ed6\u8fdb\u7a0b\u5360\u7528\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<li>\u4fee\u6539\u7aef\u53e3\u53f7&#xff1a;server.port&#061;9090\n <\/li>\n<li>\u4f7f\u7528\u968f\u673a\u7aef\u53e3&#xff1a;server.port&#061;0\n <\/li>\n<hr \/>\n<h5>6.2 \u542f\u52a8\u65f6\u95f4\u8fc7\u957f<\/h5>\n<p>\u95ee\u9898&#xff1a; \u5185\u5d4c\u670d\u52a1\u5668\u542f\u52a8\u65f6\u95f4\u8fc7\u957f\u53ef\u80fd\u4e0e\u7ebf\u7a0b\u6c60\u6216\u914d\u7f6e\u9519\u8bef\u6709\u5173\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<li>\u4f18\u5316\u7ebf\u7a0b\u6c60\u914d\u7f6e&#xff1a;server.tomcat.threads.max&#061;200\n <\/li>\n<li>\u68c0\u67e5\u662f\u5426\u52a0\u8f7d\u4e86\u591a\u4f59\u7684\u7ec4\u4ef6\u3002<\/li>\n<hr \/>\n<h5>6.3 \u5185\u5d4c\u670d\u52a1\u5668\u65e5\u5fd7\u8fc7\u591a<\/h5>\n<p>\u95ee\u9898&#xff1a; \u63a7\u5236\u53f0\u8f93\u51fa\u5927\u91cf\u5185\u5d4c\u670d\u52a1\u5668\u7684\u542f\u52a8\u65e5\u5fd7\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a; \u8c03\u6574\u65e5\u5fd7\u7ea7\u522b&#xff1a;<\/p>\n<p>logging.level.org.apache.catalina&#061;INFO<br \/>\nlogging.level.org.eclipse.jetty&#061;INFO<br \/>\nlogging.level.io.undertow&#061;INFO<\/p>\n<hr \/>\n<h4>\u4e03\u3001\u5b9e\u8df5\u6848\u4f8b&#xff1a;\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 Web \u670d\u52a1<\/h4>\n<p>\u5b8c\u6574\u793a\u4f8b&#xff1a;\u7528\u6237\u7ba1\u7406\u670d\u52a1<\/p>\n<li>\u521b\u5efa REST \u63a7\u5236\u5668&#xff1a;<\/li>\n<p><span class=\"token annotation punctuation\">&#064;RestController<\/span><br \/>\n<span class=\"token annotation punctuation\">&#064;RequestMapping<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\/users&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserController<\/span> <span class=\"token punctuation\">{<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;GetMapping<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\/{id}&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token function\">getUser<\/span><span class=\"token punctuation\">(<\/span><span class=\"token annotation punctuation\">&#064;PathVariable<\/span> <span class=\"token class-name\">String<\/span> id<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token string\">&#034;User ID: &#034;<\/span> <span class=\"token operator\">&#043;<\/span> id<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<li>\u542f\u52a8\u5e94\u7528&#xff1a;<\/li>\n<p>\u8fd0\u884c\u4e3b\u7c7b&#xff0c;\u542f\u52a8\u5185\u5d4c\u670d\u52a1\u5668\u3002<\/p>\n<p><span class=\"token annotation punctuation\">&#064;SpringBootApplication<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserServiceApplication<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> args<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">SpringApplication<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">UserServiceApplication<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">,<\/span> args<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<li>\u6d4b\u8bd5&#xff1a;<\/li>\n<p>\u8bbf\u95ee http:\/\/localhost:8080\/users\/123&#xff0c;\u5f97\u5230\u4ee5\u4e0b\u54cd\u5e94&#xff1a;<\/p>\n<p>User ID: 123<\/p>\n<hr \/>\n<h4>\u516b\u3001\u603b\u7ed3<\/h4>\n<p>Spring Boot \u7684\u5185\u5d4c\u670d\u52a1\u5668\u7279\u6027\u6781\u5927\u5730\u7b80\u5316\u4e86 Java Web \u5e94\u7528\u7684\u5f00\u53d1\u548c\u90e8\u7f72\u8fc7\u7a0b\u3002\u901a\u8fc7\u7075\u6d3b\u914d\u7f6e\u548c\u652f\u6301\u591a\u79cd\u670d\u52a1\u5668\u7c7b\u578b&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u6784\u5efa\u548c\u7ba1\u7406\u9ad8\u6027\u80fd\u7684 Web \u5e94\u7528\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u7406\u89e3\u5185\u5d4c\u670d\u52a1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u3001\u914d\u7f6e\u65b9\u5f0f\u4ee5\u53ca\u5e38\u89c1\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848&#xff0c;\u662f\u6bcf\u4f4d Spring Boot \u5f00\u53d1\u8005\u7684\u91cd\u8981\u6280\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb746\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf4\u6b21\u3002Spring Boot \u7684\u5185\u5d4c\u670d\u52a1\u5668\uff08Embedded Server\uff09\u662f\u4e00\u79cd\u5c06 Web \u670d\u52a1\u5668\u76f4\u63a5\u6253\u5305\u5230\u5e94\u7528\u4e2d\u7684\u6280\u672f\u3002\u4e0e\u4f20\u7edf Java Web \u5e94\u7528\u4e0d\u540c\uff0cSpring Boot \u5e94\u7528\u4e0d\u9700\u8981\u5728\u5916\u90e8\u5e94\u7528\u670d\u52a1\u5668\uff08\u5982 Apache Tomcat \u6216 JBoss\uff09\u4e2d\u90e8\u7f72\uff0c\u800c\u662f\u901a\u8fc7\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u8fd0\u884c JAR \u6587\u4ef6\u542f\u52a8\u81ea\u5df1\u7684\u5185\u5d4c\u670d\u52a1\u5668\u3002\u7279\u70b9\u72ec\u7acb\u8fd0\u884c\uff1a\u65e0\u9700\u4f9d\u8d56\u5916\u90e8\u670d\u52a1\u5668\uff0c\u76f4\u63a5\u8fd0\u884c JAR \u6587\u4ef6\u5373\u53ef\u3002\u7075\u6d3b\u6027\uff1a\u652f\u6301\u591a\u79cd\u5185\u5d4c\u670d\u52a1\u5668\uff08\u5982 Tomcat\u3001Jetty\u3001Undertow\uff09\u3002\u6613\u4e8e\u914d\u7f6e\uff1a\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8f7b\u677e\u8c03\u6574\u670d\u52a1\u5668\u53c2\u6570\u3002_springboot\u5185\u5d4c\u670d\u52a1\u5668<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[98,292,43],"topic":[],"class_list":["post-42079","post","type-post","status-publish","format-standard","hentry","category-server","tag-spring-boot","tag-292","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Boot \u5185\u5d4c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/42079.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb746\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf4\u6b21\u3002Spring Boot \u7684\u5185\u5d4c\u670d\u52a1\u5668\uff08Embedded Server\uff09\u662f\u4e00\u79cd\u5c06 Web \u670d\u52a1\u5668\u76f4\u63a5\u6253\u5305\u5230\u5e94\u7528\u4e2d\u7684\u6280\u672f\u3002\u4e0e\u4f20\u7edf Java Web \u5e94\u7528\u4e0d\u540c\uff0cSpring Boot \u5e94\u7528\u4e0d\u9700\u8981\u5728\u5916\u90e8\u5e94\u7528\u670d\u52a1\u5668\uff08\u5982 Apache Tomcat \u6216 JBoss\uff09\u4e2d\u90e8\u7f72\uff0c\u800c\u662f\u901a\u8fc7\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u8fd0\u884c JAR \u6587\u4ef6\u542f\u52a8\u81ea\u5df1\u7684\u5185\u5d4c\u670d\u52a1\u5668\u3002\u7279\u70b9\u72ec\u7acb\u8fd0\u884c\uff1a\u65e0\u9700\u4f9d\u8d56\u5916\u90e8\u670d\u52a1\u5668\uff0c\u76f4\u63a5\u8fd0\u884c JAR \u6587\u4ef6\u5373\u53ef\u3002\u7075\u6d3b\u6027\uff1a\u652f\u6301\u591a\u79cd\u5185\u5d4c\u670d\u52a1\u5668\uff08\u5982 Tomcat\u3001Jetty\u3001Undertow\uff09\u3002\u6613\u4e8e\u914d\u7f6e\uff1a\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8f7b\u677e\u8c03\u6574\u670d\u52a1\u5668\u53c2\u6570\u3002_springboot\u5185\u5d4c\u670d\u52a1\u5668\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/42079.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-06T03:15:41+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42079.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/42079.html\",\"name\":\"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-06T03:15:41+00:00\",\"dateModified\":\"2025-06-06T03:15:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/42079.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/42079.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42079.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/42079.html","og_locale":"zh_CN","og_type":"article","og_title":"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb746\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf4\u6b21\u3002Spring Boot \u7684\u5185\u5d4c\u670d\u52a1\u5668\uff08Embedded Server\uff09\u662f\u4e00\u79cd\u5c06 Web \u670d\u52a1\u5668\u76f4\u63a5\u6253\u5305\u5230\u5e94\u7528\u4e2d\u7684\u6280\u672f\u3002\u4e0e\u4f20\u7edf Java Web \u5e94\u7528\u4e0d\u540c\uff0cSpring Boot \u5e94\u7528\u4e0d\u9700\u8981\u5728\u5916\u90e8\u5e94\u7528\u670d\u52a1\u5668\uff08\u5982 Apache Tomcat \u6216 JBoss\uff09\u4e2d\u90e8\u7f72\uff0c\u800c\u662f\u901a\u8fc7\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u8fd0\u884c JAR \u6587\u4ef6\u542f\u52a8\u81ea\u5df1\u7684\u5185\u5d4c\u670d\u52a1\u5668\u3002\u7279\u70b9\u72ec\u7acb\u8fd0\u884c\uff1a\u65e0\u9700\u4f9d\u8d56\u5916\u90e8\u670d\u52a1\u5668\uff0c\u76f4\u63a5\u8fd0\u884c JAR \u6587\u4ef6\u5373\u53ef\u3002\u7075\u6d3b\u6027\uff1a\u652f\u6301\u591a\u79cd\u5185\u5d4c\u670d\u52a1\u5668\uff08\u5982 Tomcat\u3001Jetty\u3001Undertow\uff09\u3002\u6613\u4e8e\u914d\u7f6e\uff1a\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8f7b\u677e\u8c03\u6574\u670d\u52a1\u5668\u53c2\u6570\u3002_springboot\u5185\u5d4c\u670d\u52a1\u5668","og_url":"https:\/\/www.wsisp.com\/helps\/42079.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-06T03:15:41+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/42079.html","url":"https:\/\/www.wsisp.com\/helps\/42079.html","name":"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-06T03:15:41+00:00","dateModified":"2025-06-06T03:15:41+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/42079.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/42079.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/42079.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Spring Boot \u5185\u5d4c\u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/42079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=42079"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/42079\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=42079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=42079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=42079"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=42079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}