摘要: Resources目录下的xml配置图: 数据库的配置,db.properties: jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&characterEnc 阅读全文
posted @ 2022-03-19 19:26 Fu_Zhang 阅读(73) 评论(0) 推荐(0)
摘要: 整合SSM时,我们需要导入各种依赖:spring,spring-jdbc,AOP,mybatis,mybatis-spring,C3P0,mysql,servlet,junit,json,JSP(可不要),并且我们配置好防止静态资源导出的问题 <?xml version="1.0" encoding 阅读全文
posted @ 2022-03-19 14:18 Fu_Zhang 阅读(1226) 评论(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-instance 阅读全文
posted @ 2022-03-05 21:06 Fu_Zhang 阅读(49) 评论(0) 推荐(0)
摘要: 我们在使用完全注解开发的时候,我们需要注意:创建一个类,代替xml配置,使用@Configuration注解代替xml, 再在这个类里面提够一个实体类的方法,返回new 这个对象,使用@Bean注解代替xml中的bean pojo层: package com.fu.pojo; import org. 阅读全文
posted @ 2022-03-04 20:15 Fu_Zhang 阅读(42) 评论(0) 推荐(0)
摘要: 基于半注解的方式开发: 我们在使用注解开发的时候需要注意: 1.在xml中配置相关的资源, 2.在xml中开启支持注解开发 3.在xml中配置,使具体包下面的类的注解生效 4.在pojo层的注解为:@Component 在dao层的注解为:@Repository 在service层下面的注解为:@S 阅读全文
posted @ 2022-03-04 19:41 Fu_Zhang 阅读(33) 评论(0) 推荐(0)
摘要: 我们使用注解开发的时候,需要注意:在xml中配置,并且开启注解的方式, 使用注解装配bean的方式有2中: 方式一:@Autowired注解搭配@Qualifier注解确定某一个具体的bean,自动装配过程:ByType再到ByName 方式二:@Resource( name = "value")的 阅读全文
posted @ 2022-03-04 19:20 Fu_Zhang 阅读(59) 评论(0) 推荐(0)
摘要: Spring的自动装配,基于xml的方式,使用byName或者byType的方式 在bean中我们使用自动装配,有2种方式:byName或者byType byName的方式:使用该方式,我们的id属性的值必需和实体类中set方法的后面的名字相同 byType的方式:使用该方式,我们注册bean的时候 阅读全文
posted @ 2022-03-04 18:59 Fu_Zhang 阅读(65) 评论(0) 推荐(0)
摘要: Spring-基于xml实现Hello World-拓展注入,C注入和P注入 注意点:我们在使用拓展注入的时候需要导入相应的依赖 本例子的xml中配置的C注入和P注入 在我们使用拓展注入的时候,我们需要在xml的配置文件中导入相应的依赖: xmlns:c="http://www.springfram 阅读全文
posted @ 2022-03-04 17:14 Fu_Zhang 阅读(40) 评论(0) 推荐(0)
摘要: 基于xml配置实现有参构造创建对象 有参构造创建对象的方式有3种,本例子采用有参构造创建对象 通过参数的类型实现,当参数类型相同时,无法处理 不推荐使用这种方式 pojo层: package com.fu.pojo; public class Hello { private String str; 阅读全文
posted @ 2022-03-04 16:50 Fu_Zhang 阅读(29) 评论(0) 推荐(0)
摘要: 基于xml配置实现有参构造创建对象 有参构造创建对象的方式有3种,本例子采用有参构造创建对象 通过下标给对象赋值 pojo层: package com.fu.pojo; public class Hello { private String str; public Hello() { System. 阅读全文
posted @ 2022-03-04 16:43 Fu_Zhang 阅读(25) 评论(0) 推荐(0)