• spring 基础回想 tips01


    版权声明:本文为博主原创文章。未经博主同意不得转载。

    https://blog.csdn.net/huangbin10025/article/details/37048685

    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>


     

     

  • 相关阅读:
    V4L2 soccamera 子系统
    ubuntu10.04 vim 配置
    Video for Linux Two
    I2C总线的仲裁机制
    Android Camera 通过V4L2与kernel driver的完整交互过程
    ubuntu安装辞典
    v4l2 camera 驱动架构 之 isp controller 驱动
    Android Camera 运行流程
    CentOS 7.x安装图文示范
    同余与模运算
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10913928.html
  • Copyright © 2020-2023  润新知