03 2023 档案

摘要:package com.feijian; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import 阅读全文
posted @ 2023-03-31 15:17 Rui2022 阅读(64) 评论(0) 推荐(0) 编辑
摘要:在settings中 选择MySQL 阅读全文
posted @ 2023-03-27 12:03 Rui2022 阅读(31) 评论(0) 推荐(0) 编辑
摘要:阿里巴巴开发的JSON <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.60</version> </dependency> @RequestMapping( "/j 阅读全文
posted @ 2023-03-24 21:13 Rui2022 阅读(9) 评论(0) 推荐(0) 编辑
摘要:公共类 package com.feijian.utils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import c 阅读全文
posted @ 2023-03-24 20:59 Rui2022 阅读(13) 评论(0) 推荐(0) 编辑
摘要:1\JSON复习 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript"> var user ={ name:"飞剑", ag 阅读全文
posted @ 2023-03-24 20:04 Rui2022 阅读(15) 评论(0) 推荐(0) 编辑
摘要:一、TOMCAT CONFIG文件配置: <Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" URIEncoding="UTF-8"/> 二、springmvc自带过滤配置 <! 阅读全文
posted @ 2023-03-24 15:48 Rui2022 阅读(13) 评论(0) 推荐(0) 编辑
摘要:@Controller @RequestMapping("/user") public class UserController { @GetMapping("/t1") //一般都加上@ReuestParam,避免前端传递的参数名字和后端不一致 public String test1(@Reque 阅读全文
posted @ 2023-03-24 14:57 Rui2022 阅读(14) 评论(0) 推荐(0) 编辑
摘要:第一种:实现接口Controller定义控制器是比较老的办法 缺点:一个控制器只有一个方法,如果有多个方法需要定义多个controller,定义方式比较麻烦 第二种:使用注解 @Controller 视图可以被复用 几种常用的注解 @Component 组件 @Service service @Co 阅读全文
posted @ 2023-03-23 22:06 Rui2022 阅读(16) 评论(0) 推荐(0) 编辑
摘要:真实开发-注解开发 1、 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in 阅读全文
posted @ 2023-03-22 22:02 Rui2022 阅读(17) 评论(0) 推荐(0) 编辑
摘要:图为SpringMVC的一个较完整的流程图,实线表示SpringMVC框架提供的技术,不需要开发者实现,虚线表示需要开发者实现。 简要分析执行流程 1\DispatcherServlet表示前置控制器,是整个SpringMVC的控制中心。用户发出请求,DispatcherServlet接收请求并拦截 阅读全文
posted @ 2023-03-22 20:59 Rui2022 阅读(15) 评论(0) 推荐(0) 编辑
摘要:参考网页:https://www.kuangstudy.com/bbs/1618521039124783105 第1步:注册web.xml,注册DispatcherServlet <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http: 阅读全文
posted @ 2023-03-21 20:51 Rui2022 阅读(16) 评论(0) 推荐(0) 编辑
摘要:1、欢迎页设置 在web 文件夹下新建form.jsp : input 的类型是text,名字是:method。 一旦输入 add 或 delete 提交, 就会到HelloServlet进行跳转 <%-- Created by IntelliJ IDEA. User: Administrator 阅读全文
posted @ 2023-03-20 22:38 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:第1步:配置Maven,新建module, 并添加框架支持,变为web项目 <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </de 阅读全文
posted @ 2023-03-20 20:35 Rui2022 阅读(11) 评论(0) 推荐(0) 编辑
摘要:遵循ACID原则,这样保证批量事务其中一项报错,整个批量事务都不执行。 案例:在spring-dao.xml中加载 aop 和 tx 注意细节:xmlns: aop(或tx)要有整个名字, 另外注意 > 和 “”的位置和范围 <?xml version="1.0" encoding="UTF-8"? 阅读全文
posted @ 2023-03-19 22:36 Rui2022 阅读(8) 评论(0) 推荐(0) 编辑
摘要:进一步优化 将UserMapperImpl 进行优化,继承系统提供的一个父类:extends SqlSessionDaoSupport 新建一个:UserMapperImpl2类 继承父类,实现UserMapper接口 。简化成一行代码 package com.feijian.mapper; imp 阅读全文
posted @ 2023-03-19 10:09 Rui2022 阅读(12) 评论(0) 推荐(0) 编辑
摘要:在配置前要加载依赖以及build (pom.xml中添加各种依赖)以及连接数据库 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w 阅读全文
posted @ 2023-03-19 09:43 Rui2022 阅读(12) 评论(0) 推荐(0) 编辑
摘要:AOP方法一:通过Spring API接口实现 <bean id="userService" class="com.feijian.service.UserServiceImpl"/> <bean id="log" class="com.feijian.log.Log"/> <bean id="af 阅读全文
posted @ 2023-03-18 20:33 Rui2022 阅读(12) 评论(0) 推荐(0) 编辑
摘要:一个动态代理接口类,可以作为工具接口,便于不同程序公共使用 package com.feijian.Demo02; import com.feijian.Demo.Rent; import com.sun.corba.se.impl.ior.OldJIDLObjectKeyTemplate; imp 阅读全文
posted @ 2023-03-18 17:10 Rui2022 阅读(16) 评论(0) 推荐(0) 编辑
摘要:第一:接口类(增删改查) package com.feijian.Service; public interface UserService { public void addUser(); public void updateUser(); public void deleteUser(); pu 阅读全文
posted @ 2023-03-18 16:58 Rui2022 阅读(18) 评论(0) 推荐(0) 编辑
摘要:反射机制,反过来,通过修改配置文件达到更新,拓展程序的目的,而不需要修改代码 传统方法:对象.方法() 反射机制:方法.invoke(对象) 实体类及方法 package com.feijian; public class Cat { public String name="招财猫: "; publ 阅读全文
posted @ 2023-03-18 13:45 Rui2022 阅读(16) 评论(0) 推荐(0) 编辑
摘要:纵向开发后,如果需要向其中一个层增加内容,比如日志记录,这样就需要使用横向编程的思维:也就是代理机制,代理类有某层的业务方法,同时增加新的业务方法进去。 这样的好处在于不要再去修改之前的各层的代码,直接调用即可。避免了已有程序代码的修改。 第一:接口类 package com.feijian.Ser 阅读全文
posted @ 2023-03-18 10:37 Rui2022 阅读(11) 评论(0) 推荐(0) 编辑
摘要:角色框架图 代码顺序: 1、接口 :抽象角色 interface package com.feijian.pojo; public interface Rent { public void rent(); } 2、真实角色:房东 纯粹业务:出租房子 package com.feijian.pojo; 阅读全文
posted @ 2023-03-18 09:49 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:JavaConfig 是Spring的一个子项目。4之后变为了一个核心功能 @Configuration //代表这是一个配置类,和beans.xml是一个效果。等同于 @ComponentScan("com.feijian.pojo") public class FeijianConfig { / 阅读全文
posted @ 2023-03-16 19:59 Rui2022 阅读(11) 评论(0) 推荐(0) 编辑
摘要:第一:使用注解开发必须导入AOP的包加载依赖了。spring-webmvc 第二:在使用注解需要导入context约束,增加注解的支持 在beans.xml文件中 第三:@component //@component 组件,相当于在配置文件中bean的动作 第四:@属性注入:在setf方法上增加语句 阅读全文
posted @ 2023-03-16 19:26 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:1、配置XML 注解支持: <context:annotation-config/> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi 阅读全文
posted @ 2023-03-16 07:58 Rui2022 阅读(11) 评论(0) 推荐(0) 编辑
摘要:自动装配Bean 两种自动装配方法:第一byName ,第二byType 属性类型(用byType可以省略写id)。 byName 要保证所有bean的id必须唯一 ,这个bean 必须和自动注入的属性set方法的值一致 <?xml version="1.0" encoding="UTF-8"?> 阅读全文
posted @ 2023-03-15 20:44 Rui2022 阅读(7) 评论(0) 推荐(0) 编辑
摘要:作用域 ,两种 第一种:是单例模式,相当于公共 singleton 这个模式为默认模式,可以不显式写出 第二种:原型模式,相对于每一次取bean 都生成新的对象。 prototype 阅读全文
posted @ 2023-03-15 19:55 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:DI依赖注入 :set注入 依赖:bean对象的创建依赖于容器 注入:bean对象中的所有属性,由容器注入 复杂类型注入:Address Student两个类 public class Address { private String address; public class Student { 阅读全文
posted @ 2023-03-15 07:24 Rui2022 阅读(9) 评论(0) 推荐(0) 编辑
摘要:别名 <alias name="user" alias="usernew"/> 配置 其中的name,也是别名,而且可以取多个别名 <bean id="user" class="com.feijian.pojo.User" name="user2,user3,user4"> <constructor 阅读全文
posted @ 2023-03-15 06:34 Rui2022 阅读(13) 评论(0) 推荐(0) 编辑
摘要:无参构造器 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in 阅读全文
posted @ 2023-03-14 21:10 Rui2022 阅读(8) 评论(0) 推荐(0) 编辑
摘要:把dao中 UserDao的实现类写入到beans.xml中,三个实现类。 <bean id="MySqlDaoImpl" class="com.feijian.dao.MySqlDaoImpl"/> <bean id="OracleDaoImpl" class="com.feijian.dao.O 阅读全文
posted @ 2023-03-14 20:26 Rui2022 阅读(7) 评论(0) 推荐(0) 编辑
摘要:所谓IOC 就是由Spring 创建对象,管理,装配 例子: 第一步:建立pojo包,生成Hello类 一个属性 String name, get/set方法,toString 方法 package com.feijian.pojo; public class Hello { private Str 阅读全文
posted @ 2023-03-14 19:58 Rui2022 阅读(11) 评论(0) 推荐(0) 编辑
摘要:1、Maven环境配置 <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>6.0.3</version> </depen 阅读全文
posted @ 2023-03-14 07:25 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:第二种方法,采用结果查询:但老师的ID 要和学生的TID有个对应关系 注意事宜:SQL语句需加上 t.id tid 如果不注明 查出来的老师ID 则为O <select id="getStudent2" resultMap="StudentTeacher2"> select s.id sid,s.n 阅读全文
posted @ 2023-03-13 07:09 Rui2022 阅读(68) 评论(0) 推荐(0) 编辑
摘要:在StudentMapper.xml 需要使用复杂查询的方法, 1、先单独查学生和单独查老师 2、在中间使用结果映射 学生中reultMap ="StudentTeacher" 3、中间增加结果映射 resultMap id ="StudentTeacher" type="Student" 还是学生 阅读全文
posted @ 2023-03-12 21:47 Rui2022 阅读(128) 评论(0) 推荐(0) 编辑
摘要:搭建环境 新建数据库表格,teacher 和student 两张表格 在SQLyog中 CREATE TABLE `teacher` ( `id` INT(10) NOT NULL, `name` VARCHAR(30) DEFAULT NULL, PRIMARY KEY (`id`)) ENGIN 阅读全文
posted @ 2023-03-12 21:06 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:第一步:Settings中加入plugins lombok 第二步:maven中导入依赖 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.24</versi 阅读全文
posted @ 2023-03-12 20:13 Rui2022 阅读(12) 评论(0) 推荐(0) 编辑
摘要:id 就是对应的namespace中的方法名; resultType 就是sql语句执行的返回值 (Class or 数据类型) parameterType 参数的类型 (方法名中的参数),如果为简单的数据类型,默认可以不写。 <select id="getUserById" parameterTy 阅读全文
posted @ 2023-03-12 19:49 Rui2022 阅读(11) 评论(0) 推荐(0) 编辑
摘要:第一步:pojo的属性和数据库的列名不一样 package com.feijian.pojo; public class User { private int id; private String name; private String password; public User() { } pu 阅读全文
posted @ 2023-03-12 19:38 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:属性文件: resources - > db.properties driver=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncodin 阅读全文
posted @ 2023-03-10 16:18 Rui2022 阅读(13) 评论(0) 推荐(0) 编辑
摘要:接口类 //模糊查询 List <User> getUserLike(String value); 第二步:UserMapper.xml <!--模糊查询--> <select id="getUserLike" resultType="com.feijian.pojo.User"> select * 阅读全文
posted @ 2023-03-10 15:25 Rui2022 阅读(15) 评论(0) 推荐(0) 编辑
摘要:如果实体类或数据库中太多参数,我们应该考虑用MAP int addUser2(Map<String, Object> map); Mapper.xml <insert id="addUser2" parameterType="map" > insert into mybatis.user(id,na 阅读全文
posted @ 2023-03-10 15:03 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:查,增,改,删 第一步:接口写入新方法 package com.feijian.dao; import com.feijian.pojo.User; import java.util.List; public interface UserMapper { //1.查询全部用户 List <User> 阅读全文
posted @ 2023-03-10 14:27 Rui2022 阅读(12) 评论(0) 推荐(0) 编辑
摘要:第一步:maven依赖搭建,同时把build内容加上。避免后期丢失的问题 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w 阅读全文
posted @ 2023-03-10 13:31 Rui2022 阅读(16) 评论(0) 推荐(0) 编辑
摘要:package JavaSE.Lesson18; import java.io.FileReader; import java.io.IOException; public class ReaderDemo02 { public static void main(String[] args) { S 阅读全文
posted @ 2023-03-03 21:56 Rui2022 阅读(10) 评论(0) 推荐(0) 编辑
摘要:package JavaSE.Lesson18; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class ReaderDemo { public 阅读全文
posted @ 2023-03-03 21:56 Rui2022 阅读(9) 评论(0) 推荐(0) 编辑
摘要:package JavaSE.Lesson18; import java.io.FileWriter; import java.io.IOException; public class FileWriterDemo01 { public static void main(String[] args) 阅读全文
posted @ 2023-03-03 21:53 Rui2022 阅读(15) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示