{"id":12764,"date":"2023-12-20T15:44:05","date_gmt":"2023-12-20T07:44:05","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=12764"},"modified":"2023-12-20T15:44:05","modified_gmt":"2023-12-20T07:44:05","slug":"springboot%e9%a1%b9%e7%9b%ae%e6%89%93%e5%8c%85%e6%88%90dmg%e6%80%8e%e4%b9%88%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/12764\/","title":{"rendered":"springboot\u9879\u76ee\u6253\u5305\u6210dmg\u600e\u4e48\u64cd\u4f5c?"},"content":{"rendered":"

\u5728Mac OS\u4e2d\uff0cdmg\uff08Disk Image\uff09\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u78c1\u76d8\u6620\u50cf\u6587\u4ef6\u683c\u5f0f\uff0c\u7c7b\u4f3c\u4e8eWindows\u4e2d\u7684ISO\u6587\u4ef6\u3002\u5b83\u662f\u4e00\u79cd\u865a\u62df\u7684\u78c1\u76d8\uff0c\u53ef\u4ee5\u5c06\u591a\u4e2a\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u65b9\u4fbf\u7528\u6237\u4e0b\u8f7d\u548c\u5b89\u88c5\u3002<\/p>\n

\u5bf9\u4e8eSpring Boot\u9879\u76ee\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u6253\u5305\u6210dmg\u6587\u4ef6\uff0c\u4ee5\u4fbf\u4e8eMac\u7528\u6237\u8fdb\u884c\u5b89\u88c5\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5c06Spring Boot\u9879\u76ee\u6253\u5305\u6210dmg\u6587\u4ef6\u3002<\/p>\n

1. \u51c6\u5907\u5de5\u4f5c<\/p>\n

\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u5de5\u5177\uff1a<\/p>\n

– JDK 1.8\u6216\u66f4\u9ad8\u7248\u672c<\/p>\n

– Maven<\/p>\n

– Gradle<\/p>\n

– Mac OS\u64cd\u4f5c\u7cfb\u7edf<\/p>\n

2. \u521b\u5efaSpring Boot\u9879\u76ee<\/p>\n

\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2aSpring Boot\u9879\u76ee\u3002\u53ef\u4ee5\u4f7f\u7528Maven\u6216Gradle\u6784\u5efa\u5de5\u5177\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5Maven\u4e3a\u4f8b\u3002<\/p>\n

\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

mvn archetype:generate -DgroupId=com.example -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyproject\u201d\u7684Maven\u9879\u76ee\u3002<\/p>\n

3. \u7f16\u5199\u4ee3\u7801<\/p>\n

\u5728\u521b\u5efa\u597d\u7684Spring Boot\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u7f16\u5199\u4ee3\u7801\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4e3a\u4f8b\uff0c\u521b\u5efa\u4e00\u4e2aHello World\u7a0b\u5e8f\u3002<\/p>\n

\u5728src\/main\/java\/com\/example\/myproject\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cHelloWorldController.java\u201d\u7684Java\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

@RestController<\/p>\n

public class HelloWorldController {<\/p>\n<\/p>\n

@RequestMapping(“\/”)<\/p>\n

public String hello() {<\/p>\n

return “Hello World!”;<\/p>\n

}<\/p>\n<\/p>\n

}<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u7c7b\u4f7f\u7528\u4e86Spring MVC\u6846\u67b6\uff0c\u5f53\u7528\u6237\u8bbf\u95ee\u6839\u8def\u5f84\u65f6\uff0c\u5c06\u8fd4\u56de\u201cHello World!\u201d\u5b57\u7b26\u4e32\u3002<\/p>\n

4. \u6253\u5305\u9879\u76ee<\/p>\n

\u5b8c\u6210\u4ee3\u7801\u7f16\u5199\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u9879\u76ee\u6253\u5305\u6210\u53ef\u6267\u884c\u7684jar\u6587\u4ef6\u3002\u5728\u7ec8\u7aef\u4e2d\u8fdb\u5165\u9879\u76ee\u6839\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

mvn clean package<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u5728target\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a\u540d\u4e3a\u201cmyproject-1.0-SNAPSHOT.jar\u201d\u7684\u53ef\u6267\u884cjar\u6587\u4ef6\u3002<\/p>\n

5. \u521b\u5efadmg\u6587\u4ef6<\/p>\n

\u4e3a\u4e86\u5c06\u53ef\u6267\u884cjar\u6587\u4ef6\u6253\u5305\u6210dmg\u6587\u4ef6\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u4e00\u4e2a\u540d\u4e3a\u201cappdmg\u201d\u7684\u5de5\u5177\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5appdmg\uff1a<\/p>\n

“`<\/p>\n

npm install -g appdmg<\/p>\n

“`<\/p>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyproject.dmg\u201d\u7684dmg\u6587\u4ef6\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

appdmg myproject.json myproject.dmg<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0cmyproject.json\u662f\u4e00\u4e2aJSON\u683c\u5f0f\u7684\u6587\u4ef6\uff0c\u7528\u4e8e\u6307\u5b9admg\u6587\u4ef6\u7684\u5c5e\u6027\u548c\u5185\u5bb9\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8bmyproject.json\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n

“`<\/p>\n

{<\/p>\n

“title”: “My Project”,<\/p>\n

“icon”: “icon.png”,<\/p>\n

“background”: “background.png”,<\/p>\n

“contents”: [<\/p>\n

\u628a\u521b\u5efa\u7684exe\u5c01\u5305<\/a> { “x”: 192, “y”: 344, “type”: “file”, “path”: “myproject-1.0-SNAPSHOT.jar” },<\/p>\n

{ “x”: 448, “y”: 344, “t<\/p>\n

<\/figure>\n<\/p>\n

ype”: “link”, “path”: “\/Applications” }<\/p>\n

]<\/p>\n

}<\/p>\n

uri\u6253\u5305exe<\/a>“`<\/p>\n

\u8fd9\u4e2a\u6587\u4ef6\u6307\u5b9a\u4e86dmg\u6587\u4ef6\u7684\u6807\u9898\u3001\u56fe\u6807\u3001\u80cc\u666f\u4ee5\u53ca\u5185\u5bb9\u3002contents\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u8868\u793admg\u6587\u4ef6\u4e2d\u7684\u4e00\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u3002\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u53ef\u6267\u884cjar\u6587\u4ef6\u653e\u7f6e\u5728dmg\u6587\u4ef6\u4e2d\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u5feb\u6377\u65b9\u5f0f\u5230\u201c\/Applications\u201d\u76ee\u5f55\u3002<\/p>\n

\u6267\u884c\u5b8c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u5c06\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyproject.dmg\u201d\u7684dmg\u6587\u4ef6\u3002<\/p>\n

6. \u5b89\u88c5dmg\u6587\u4ef6<\/p>\n

\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u751f\u6210\u7684dmg\u6587\u4ef6\u5206\u53d1\u7ed9Mac\u7528\u6237\u3002\u5f53\u7528\u6237\u53cc\u51fbdmg\u6587\u4ef6\u65f6\uff0c\u5c06\u4f1a\u6253\u5f00\u4e00\u4e2a\u5b89\u88c5\u5411\u5bfc\uff0c\u7528\u6237\u53ef\u4ee5\u5c06\u53ef\u6267\u884cjar\u6587\u4ef6\u62d6\u62fd\u5230\u201c\/Applications\u201d\u76ee\u5f55\u4e2d\uff0c\u4ee5\u4fbf\u4e8e\u5feb\u901f\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06Spring Boot\u9879\u76ee\u6253\u5305\u6210dmg\u6587\u4ef6\uff0c\u65b9\u4fbfMac\u7528\u6237\u8fdb\u884c\u5b89\u88c5\u548c\u4f7f\u7528\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u521b\u5efadmg\u6587\u4ef6\u65f6\uff0c\u9700\u8981\u6307\u5b9a\u597d\u6587\u4ef6\u7684\u5c5e\u6027\u548c\u5185\u5bb9\uff0c\u4ee5\u4fbf\u4e8e\u7528\u6237\u8fdb\u884c\u5b89\u88c5\u548c\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Mac OS\u4e2d\uff0cdmg\uff08Disk Image\uff09\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u78c1\u76d8\u6620\u50cf\u6587\u4ef6\u683c\u5f0f\uff0c\u7c7b\u4f3c\u4e8eWindows\u4e2d\u7684ISO\u6587\u4ef6\u3002\u5b83\u662f\u4e00\u79cd\u865a\u62df\u7684\u78c1\u76d8\uff0c\u53ef\u4ee5\u5c06\u591a\u4e2a\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u65b9\u4fbf\u7528\u6237\u4e0b\u8f7d\u548c\u5b89\u88c5\u3002\u5bf9\u4e8eSprin<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[2325,2908,16,164,23],"topic":[],"class_list":["post-12764","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-2325","tag-exe","tag-16","tag-pdyrbdtdbbxb","tag-23"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/12764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=12764"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/12764\/revisions"}],"predecessor-version":[{"id":12934,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/12764\/revisions\/12934"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=12764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=12764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=12764"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=12764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}