spring 基础回想 tips01
spring 属性注入时,类中必须有setter 和 getter方法。
spring配置文件里:
java业务类中注入DAO:
private StudentDao studentDao;
// 通过属性注入
public StudentDao getStudentDao() {
return studentDao;
} public void setStudentDao(StudentDao studentDao) {
this.studentDao = studentDao;
}
spring 构造方法注入时,要注明属性,类中不须要setter 和 getter方法,可是须要构造器对其进行赋值。
<!-- 定义studentService的bean实例 ,并注入studentDao -->
<bean id="studentService" class="com.michael.spring.business.student.StudentServiceImpl">
<constructor-arg ref="studentDao"></constructor-arg>
</bean>
java业务类中注入DAO:
private StudentDao studentDao;
// 通过属性注入
public StudentDao getStudentDao() {
return studentDao;
}
public void setStudentDao(StudentDao studentDao) {
this.studentDao = studentDao;
}
属性注入时,能够对其进行赋值,而且返回值由定义的属性值确定。
Java类中定义:
private long youknow;
public long getYouknow() {
return youknow;
}
public void setYouknow(long youknow) {
this.youknow = youknow;
}
<property name="youknow">
<value>245</value>
</property>
或者直接这样写:
<property name="youknow" value="245"></property>
spring 基础回想 tips01的更多相关文章
- Spring基础知识
Spring基础知识 利用spring完成松耦合 接口 public interface IOutputGenerator { public void generateOutput(); } 实现类 ...
- spring基础整理
spring基础教程:https://www.tutorialspoint.com/spring/spring_overview.htm 注入实例 <bean id="" c ...
- Spring 基础知识
Spring架构简单描述 原文:https://www.shiyanlou.com/courses/document/212 Spring 概述 1. Spring 是什么 Spring是一个开源的轻 ...
- Spring基础配置
从毕业到现在我一直从事Android开发,但是对JavaEE一直念念不忘,毕业校招的时候,一个礼拜拿了三个offer,岗位分别是Android.JavaEE和JavaSE,后来觉得Android比较简 ...
- Spring基础系列--AOP织入逻辑跟踪
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9619910.html 其实在之前的源码解读里面,关于织入的部分并没有说清楚,那些前置.后 ...
- 第65节:Java后端的学习之Spring基础
Java后端的学习之Spring基础 如果要学习spring,那么什么是框架,spring又是什么呢?学习spring中的ioc和bean,以及aop,IOC,Bean,AOP,(配置,注解,api) ...
- Spring基础系列-AOP源码分析
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9560803.html 一.概述 Spring的两大特性:IOC和AOP. AOP是面向切 ...
- Spring基础系列-Spring事务不生效的问题与循环依赖问题
原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9476550.html 一.提出问题 不知道你是否遇到过这样的情况,在ssm框架中开发we ...
- Spring Boot实战(1) Spring基础
1. Spring基础配置 Spring框架本身有四大原则: 1) 使用POJO进行轻量级和最小侵入式开发 2) 通过依赖注入和基于接口编程实现松耦合 3) 通过AOP和默认习惯进行声明式编程 4) ...
随机推荐
- 暴力 【p4098】[HEOI2013]ALO
Description Welcome to ALO ( Arithmetic and Logistic Online).这是一个 VR MMORPG, 如名字所见,到处充满了数学的谜题 现在你拥有 ...
- Track Cylinder
1 Track = 48 KB1 Cylinder = 720 KB so 1 Cylinder = 15 Tracks Read more: http://ibmmainframes.com/abo ...
- luogu P3305 [SDOI2013]费用流
题目链接 bz似乎挂了... luogu P3305 [SDOI2013]费用流 题解 dalao告诉我,这题 似乎很水.... 懂了题目大意就可以随便切了 问1,最大流 问2,二分最大边权求,che ...
- 【点分治】bzoj1468 Tree
同poj1741. 换了个更快的姿势,不会重复统计然后再减掉什么的啦~ #include<cstdio> #include<algorithm> #include<cst ...
- iOS消息传递机制
每个应用或多或少都由一些需要相互传递消息的对象结合起来以完成任务.在这篇文章里,我们将介绍所有可用的消息传递机制,并通过例子来介绍怎样在苹果的框架里使用.我们还会选择一些最佳范例来介绍什么时候该用什么 ...
- RowState 介绍
RowState 介绍 从不同位置载入 DataRow 后 RowState 的状态修改, 更改, 删除后的 DataRow.RowState 转化使用 AcceptChanges, RejectCh ...
- Enable a SQL Server Trace Flag Globally on Linux
https://www.mssqltips.com/sql-server-tip-category/226/sql-server-on-linux// Microsoft has recently r ...
- Word里如何打出带有上下横杠的大写字母i
换成新罗马就行了.
- Android ProgressBar手动控制开始和停止
这两天有个需求,点击按钮从SD卡解压压缩包,并读取压缩包内txt文档内容,然后在街面上显示出来.毕竟IO操作很耗时,如果文件较大会花费不少时间.所以,在处理数据的时候能给个进度就好了.我们通常的做法就 ...
- DEDECMS之0day入侵总结
1.查看dedecms最后升级版本:http://xxx.com/data/admin/ver.txt 2.利用网上公开之0day进行对应版本之入侵 ps:dedecms默认CMS后台:http:// ...