﻿{"id":981,"date":"2022-12-27T10:32:39","date_gmt":"2022-12-27T02:32:39","guid":{"rendered":"http:\/\/blog.sway.com.cn\/?p=981"},"modified":"2022-12-29T20:18:43","modified_gmt":"2022-12-29T12:18:43","slug":"springboot%e5%ae%9e%e7%8e%b0commandlinerunner%e8%bf%90%e8%a1%8cjavafx","status":"publish","type":"post","link":"http:\/\/blog.sway.com.cn\/?p=981","title":{"rendered":"Springboot2.7.x\u5b9e\u73b0CommandLineRunner\u8fd0\u884cJavaFX"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Application\u5165\u53e3\u6539\u9020<\/h2>\n\n\n\n<p>\u5b9e\u73b0\u63a5\u53e3CommandLineRunner\uff0c\u5e76\u4e14\u91cd\u5199run()\u65b9\u6cd5\uff0c\u4fbf\u53ef\u4ee5\u5728springboot\u542f\u52a8\u65f6\u540c\u65f6\u8fd0\u884c\u4e00\u6bb5\u65b9\u6cd5\uff0c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import javafx.application.Application;\nimport org.springframework.boot.CommandLineRunner;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class TestApplication implements CommandLineRunner {\n\n    public static void main(String[] args) {\n        SpringApplication.run(TestApplication .class, args);\n    }\n\n    @Override\n    public void run(String... args) throws Exception {\n        Application.launch(MainApp.class, args);\n    }\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u521b\u5efa\u7a97\u4f53\u7a0b\u5e8f<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import javafx.application.Application;\nimport javafx.scene.Scene;\nimport javafx.scene.layout.AnchorPane;\nimport javafx.stage.Stage;\n\npublic class MainApp extends Application {\n\n    @Override\n    public void start(Stage primaryStage) throws Exception {\n        AnchorPane anchorPane=new AnchorPane();\n        Scene scene=new Scene(anchorPane, 200, 150);\n        primaryStage.setScene(scene);\n        primaryStage.show();\n    }\n\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8fd0\u884c\u6548\u679c<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-37.png\"><img loading=\"lazy\" decoding=\"async\" width=\"276\" height=\"226\" src=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-37.png\" alt=\"\" class=\"wp-image-984\"\/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Application\u5165\u53e3\u6539\u9020 \u5b9e\u73b0\u63a5\u53e3CommandLineRunner\uff0c\u5e76\u4e14\u91cd\u5199run()\u65b9\u6cd5\uff0c\u4fbf\u53ef\u4ee5\u5728s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-981","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=981"}],"version-history":[{"count":3,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/981\/revisions"}],"predecessor-version":[{"id":987,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/981\/revisions\/987"}],"wp:attachment":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=981"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}