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

网站导航条代码seo优化培训公司

网站导航条代码,seo优化培训公司,毕业设计做网站应该学什么,做网站用什么电脑好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/25560.html

相关文章:

  • 越南做网站google推广一年3万的效果
  • 福州企业做网站淘宝网站的推广与优化
  • 网站应具有的功能模块查网站流量查询工具
  • 网课代理seo 优化思路
  • 做网络销售哪些网站比较好生猪价格今日猪价
  • 电子商务网站推广实训报告学it什么培训机构好
  • 做儿童业态招商要去哪些网站宁波seo公司排名
  • 用php做商城网站的设计论文清远今日头条新闻
  • 义乌网站建设郭友情链接导航
  • 制作二维码的软件百度seo如何快速排名
  • 什么是网站和网页代发新闻稿最大平台
  • 建设企业网站的意义优化营商环境发言材料
  • 做批发比较好的网站有哪些百度推广登录后台登录入口
  • 将网站做成logo怎么做今日舆情热点
  • 石碣网站建设广州seo成功案例
  • 修改网站版权外包公司软件开发
  • 网站打不开怎么回事网站页面优化包括
  • 张店网站建设方案百度推广客服电话人工服务
  • 手机浏览器主页网站推荐百度投诉中心在线申诉
  • 前端网站开发实例视频百度竞价员
  • 做综合医院网站做网站找哪家好
  • 没有公众号建微信网站seo网站排名优化公司哪家好
  • 网站开发怎么挣外快登封搜索引擎优化
  • 推广策略用英语怎么说安徽网站优化
  • 网站建设在哪里接单宁波seo外包引流推广
  • 做网站需要具备什么语言舟山seo
  • 国内谷歌网站SEO优化艾瑞指数
  • 为男人做购物网站2024年3月新冠高峰
  • wordpress修正用户注册页面长沙百度网站优化
  • 大学生毕业设计网站免费观看行情软件网站下载