当前位置: 首页 > news >正文

asp企业网站源码站长工具流量统计

asp企业网站源码,站长工具流量统计,美橙互联网站备案,视频制作网站推荐springboot整合javafx时候,很多问题就在于controller没有被spring容器管理,无法注入bean,在这里提供一套自己的解决思路 执行逻辑 这里仅仅提供一个演示,我点击按钮之后,从service层返回一个文本并显示 项目结构 创…

springboot整合javafx时候,很多问题就在于controller没有被spring容器管理,无法注入bean,在这里提供一套自己的解决思路

 

执行逻辑

这里仅仅提供一个演示,我点击按钮之后,从service层返回一个文本并显示
PixPin_2024-12-13_23-26-38.gif

项目结构

创建一个springboot项目
image.png

 

关键代码

springboot启动类中

image.png
FXApplication启动类中
image.png

全部代码

仅作示例,自行修改
 

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.4.0</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.shkj</groupId><artifactId>video-classification</artifactId><version>0.0.1-SNAPSHOT</version><name>video-classification</name><description>video-classification</description><url/><licenses><license/></licenses><developers><developer/></developers><scm><connection/><developerConnection/><tag/><url/></scm><properties><java.version>17</java.version><javafx.version>21-ea+24</javafx.version><mybatis-plus-boot-stater.version>3.5.6</mybatis-plus-boot-stater.version><mysql-connector-java.varsion>8.0.18</mysql-connector-java.varsion><druid.version>1.1.23</druid.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.openjfx</groupId><artifactId>javafx-base</artifactId><version>${javafx.version}</version></dependency><dependency><groupId>org.openjfx</groupId><artifactId>javafx-controls</artifactId><version>${javafx.version}</version></dependency><dependency><groupId>org.openjfx</groupId><artifactId>javafx-fxml</artifactId><version>${javafx.version}</version></dependency><dependency><groupId>org.openjfx</groupId><artifactId>javafx-media</artifactId><version>${javafx.version}</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql-connector-java.varsion}</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-annotation</artifactId><version>${mybatis-plus-boot-stater.version}</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>${mybatis-plus-boot-stater.version}</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-annotation</artifactId><version>${mybatis-plus-boot-stater.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>${druid.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

VideoClassificationApplication

package com.shkj.videoclassification;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;@SpringBootApplication(scanBasePackages = "com.shkj.videoclassification")
public class VideoClassificationApplication   {public static ConfigurableApplicationContext applicationContext;public static void main(String[] args) {applicationContext=SpringApplication.run(VideoClassificationApplication.class, args);FXApplication.main(args);}}

FXApplication


package com.shkj.videoclassification;import com.shkj.videoclassification.controller.HelloController;
import com.shkj.videoclassification.service.impl.TestServiceImpl;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.util.Callback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;import java.io.IOException;/*** @author shkj-大地* @create 2024-12-13 21:41* @description:*/
public class FXApplication  extends Application {@Overridepublic void start(Stage stage) throws IOException {FXMLLoader fxmlLoader = new FXMLLoader(VideoClassificationApplication.class.getResource("/view/hello.fxml"));// 注入fxmlLoader.setControllerFactory(VideoClassificationApplication.applicationContext::getBean);Scene scene = new Scene(fxmlLoader.load());stage.setTitle("Hello!");stage.setScene(scene);stage.show();}public static void main(String[] args) {launch(args);}}

application.yaml

这里也就是你自己平时用的连接数据库的配置,还想看我的?

hello.fxml 一个简单的页面

<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?><AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1"xmlns:fx="http://javafx.com/fxml/1"fx:controller="com.shkj.videoclassification.controller.HelloController"><children><Button onAction="#onButtonClick" layoutX="210.0" layoutY="272.0" mnemonicParsing="false"prefHeight="63.0" prefWidth="181.0" text="Button" /><Label fx:id="textLabel" layoutX="181.0" layoutY="83.0" prefHeight="95.0" prefWidth="239.0" text="Label" /></children>
</AnchorPane>

HelloController

package com.shkj.videoclassification.controller;import com.shkj.videoclassification.service.TestService;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;/*** @author shkj-大地* @create 2024-12-13 21:36* @description:*/
@Component
public class HelloController {@Autowiredprivate TestService testService;@FXMLpublic Label textLabel;@FXMLpublic void onButtonClick(ActionEvent actionEvent) {String test = testService.test();textLabel.setText("Hello World!"+test);}
}

TestServiceImpl


package com.shkj.videoclassification.service.impl;import com.shkj.videoclassification.service.TestService;
import org.springframework.stereotype.Service;/*** @author shkj-大地* @create 2024-12-13 21:45* @description:*/
@Service
public class TestServiceImpl  implements TestService {@Overridepublic String test() {//你自己去写数据库查询语句吧//到这里了还用我教你?return "我是service测试信息";}
}

TestService

package com.shkj.videoclassification.service;/*** @author shkj-大地* @create 2024-12-13 21:44* @description:*/
public interface TestService {String test();
}
http://www.shuangfujiaoyu.com/news/60562.html

相关文章:

  • 广告图案大全图片seo简介
  • 怎么做夜场网站打造龙头建设示范
  • 可以做3d电影网站电商营销的策略与方法
  • 洪梅镇网站仿做长沙网站建设
  • 一诺互联 网站建设专业网络推广公司排名
  • 给别人做网站前要问些什么问题市场调研方法有哪些
  • 公司管理做seo的公司
  • 网站建筑设计广州google推广
  • seo 刷网站urlseo软件优化工具软件
  • 网站备案 多久网络推广方案范文
  • wordpress 整站ssl优化推广什么意思
  • 网站内部链接优化方法seo网站推广工作内容
  • 中国住建部网站查询网百度关键词多少钱一个月
  • 富阳网站建设价格慧聪网
  • 刚开始做网站布局很吃力 怎么办网页生成器
  • 蛋糕网站建设末班成都新闻最新消息
  • 设计成功一个电子商务网站软文营销定义
  • wordpress文字排版google搜索排名优化
  • 泰安疫情最新情况青岛神马排名优化
  • 汽车网站模板优化大师怎么样
  • 网站建设活动浙江网络推广
  • wordpress安装引导页安徽seo优化
  • 专线可以做网站苏州关键词优化软件
  • jsp网站开发目的及意义seo网站排名优化软件
  • 烟台cms建站模板菏泽seo
  • 网站设计策划书方案福州网站关键词推广
  • 长沙网站优化诊断中文搜索引擎大全
  • 网站维保方法2345网址导航安装
  • 广州电子商城网站百家号查询排名数据查询
  • 网站的建设目标淘宝推广哪种方式最好