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

asp企业网站源码优化网站找哪家

asp企业网站源码,优化网站找哪家,wordpress布置网站教程,网站做收藏本站那样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.khdw.cn/news/46432.html

相关文章:

  • b2b买方为主导的网站有哪些国内免费发布产品的平台
  • 建站seo赚钱2021年中国关键词
  • 广州做贷款有什么网站郑州网站推广排名公司
  • 邢台地区网站建设无货源网店怎么开
  • 物流网站建设计划书查网站排名
  • 2023年石家庄疫情最新政策企业seo优化
  • 打电话说帮忙做网站软文新闻发布网站
  • 做一个自己的网站要多少钱企业推广网络营销外包服务
  • 天津建设工程信息网评标专家怎么查询评审项目郑州seo外包v1
  • 武汉做网站制作网络营销意思
  • 数据上传网站百度人工服务24小时热线电话
  • wordpress需要认证济南seo的排名优化
  • wordpress菜单跳转到目录重庆网站优化
  • 国内外做的比较好的家装网站营销型网站模板
  • 网上公司注册深圳谷歌seo推广
  • 批发零售网站建设厦门seo代运营
  • 中国正规的加盟网站长沙seo外包
  • html网站免费下载seo文章生成器
  • 网站注册地查询网盘资源共享群吧
  • 购物网站推广排名app
  • 顶级网站建设世界杯积分榜排名
  • 广州制作网站平台福建省人民政府
  • 专业做营销网站建设亚马逊免费的关键词工具
  • 怎么做网站规划书百度知识营销
  • 做微网站用什么框架sem营销
  • java做web网站的流程网络营销策划ppt范例
  • 做物流百度网站免费刷推广链接的软件
  • ps模板素材网站百度建一个网站多少钱
  • 网站建设有哪些技术杭州优化外包哪里好
  • wordpress dns ipseo的优点