<?xml version="1.0" encoding="UTF-8"?>
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.4.1
com.ls
boot-mybatis-javafx
0.0.1-SNAPSHOT
boot-mybatis-javafx
boot-mybatis-javafx
2.application.yml内容
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
mybatis:
mapper-locations: classpath:com/ls/mapper/*.xml
3.启动类BootMybatisJavafxApplication.java内容
由于@FXMLController控制器无法由spring管理,所用@Autowire无法自动注入,写了一个静态方法getContext获取上下文,再通过getBean()获取指定的bean
package com.ls.bootmybatisjavafx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Screen;
import javafx.stage.Stage;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
@MapperScan(value = {“com.ls.bootmybatisjavafx.mapper”}) // mybatis扫包
public class BootMybatisJavafxApplication extends Application {
}
4.Login.fxml内容(此文件放在resources目录下)
通过idea右键创建后 鼠标移动到文件 右键 Open In SceneBuilder 打开后在SceneBuilder 画图保存后会在当前文件自动生成代码(前提是吧SceneBuilder整合进idea)
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.PasswordField?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.text.Font?> <?import javafx.scene.text.Text?>
import com.ls.bootmybatisjavafx.BootMybatisJavafxApplication;
import com.ls.bootmybatisjavafx.mapper.UserMapper;
import com.ls.bootmybatisjavafx.vo.User;
import de.felixroske.jfxsupport.FXMLController;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContext;
}
6.User.java内容
package com.ls.bootmybatisjavafx.vo;
import lombok.Data;
import java.io.Serializable;
}
7.UserMapper内容
package com.ls.bootmybatisjavafx.mapper;
import com.ls.bootmybatisjavafx.vo.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserMapper {
User login(User tmp);
int register(User tmp);
int selectByName(User tmp);
}
三、运行截图
四、数据库sql文件内容
create table demo.user
(
user_id int(32) auto_increment comment ‘用户id’
primary key,
user_name varchar(32) null comment ‘用户名称’,
user_password varchar(32) null comment ‘用户密码’,
);
到此这篇junit包怎么导入(junit包怎么导入eclipse)的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/cjjbc/25641.html