1.init-method="init"

public class HelloWorldServiceImpl implements HelloWorldService {

    private String msg;

    public void init(){
this.msg="hellword";
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
}
<bean id="HelloWorld" class="com.ltf.captha.serviceImpl.HelloWorldServiceImpl" init-method="init">
<property name="msg">
<value>helloworld</value>
</property>
</bean>

2.实现org.springframework.beans.factory.InitializingBean中的afterPropertiesSet

public class HelloWord implements InitializingBean{
private String msg;
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void afterPropertiesSet() throws Exception {
this.msg="hello";
} }

spring随手笔记2:初始化方法的更多相关文章

  1. Spring管理的bean初始化方法的三种方式,以及@PostConstruct不起作用的原因

    1:Spring 容器中的 Bean 是有生命周期的,spring 允许 Bean 在初始化完成后以及销毁前执行特定的操作.下面是常用的三种指定特定操作的方法: 通过实现InitializingBea ...

  2. spring随手笔记3:销毁方法

    1. public class HelloWorld { private String msg; public void setMsg(String msg) { this.msg = msg; } ...

  3. Spring学习笔记之初始化和销毁方法的调用次序

    Multiple lifecycle mechanisms configured for the same bean, with different initialization methods, a ...

  4. spring随手笔记4:ref的属性

    1.local属性 引用在同一个xml的bean           只能引用bean的id <bean id="HelloWord" class="com.ltf ...

  5. spring随手笔记1:constructor-arg

    <bean id="Hello" class="com.ltf.captha.serviceImpl.HelloWorldServiceImpl"> ...

  6. spring 在web容器启动时执行初始化方法

    开发框架:spingMVC+myBatis 解决方案:给web容器添加一个Listener类,在容器启动的时候执行Listener的“初始化”方法,在这个初始化方法中执行查询数据库的所有操作,然后将数 ...

  7. Spring在Web容器启动时执行初始化方法

    需求:在tomcat启动时开启一个定时任务. 想法:容器启动时执行方法,最容易想到的就是servlet中可以配置load-on-startup,设置一个正整数也就可以随容器一起启动. 问题:上面的方法 ...

  8. 七、spring生命周期之初始化和销毁方法

    一.通过@Bean指定初始化和销毁方法 在以往的xml中,我们是这样配置的 <bean id="exampleInitBean" class="examples.E ...

  9. Spring项目启动时执行初始化方法

    一.applicationContext.xml配置bean <bean id="sensitiveWordInitUtil" class ="com.hx.daz ...

随机推荐

  1. qunit学习(一)

    QUnit是一个强大的JavaScript单元测试框架,用于调试代码.该框架是由jQuery团队的成员所开发,并且是jQuery的官方测试套件.任意正规JavaScript代码QUnit都能测试. 其 ...

  2. Coursera台大机器学习课程笔记3 – 机器学习的可能性

    提纲: 机器学习为什么可能? 引入计算橙球概率问题 通过用Hoeffding's inequality解决上面的问题,并得出PAC的概念,证明采样数据学习到的h的错误率可以和全局一致是PAC的 将得到 ...

  3. CSS3 border-image详解、应用

    一.border-image的兼容性 border-image可以说是CSS3中的一员大将,将来一定会大放光彩,其应用潜力真的是非常的惊人.可惜目前支持的浏览器有限,仅Firefox3.5,chrom ...

  4. html drag 拖拽用法和注意事项

    1.拖拽过程中的事件暂时jQuery里还没有,只能通过html DOM 来进行绑定,不然无法获取dataTransfer对象 2.在dragstart .dragover 等事件中可以用 evt.pr ...

  5. Javascript图片无缝滚动

    http://www.cnblogs.com/shouce/p/5068787.html

  6. Apple开发者账号简介

    苹果对开发者主要分为3类:个人.组织(公司.企业).教育机构.即: 1.个人(Individual) 2.组织(Organizations) 组织类又分为2个小类: (1)公司(Company) (2 ...

  7. free查看可用缓存

    本篇转自:http://www.cnblogs.com/coldplayerest/archive/2010/02/20/1669949.html 解释一下Linux上free命令的输出. 下面是fr ...

  8. html+css复习之第3篇 | jquery | bootstrap

    html+css复习之第3篇 | jquery  | bootstrap

  9. ssh 免密码登录

    1.在本机下生成公钥/私钥对. ssh-keygen -t rsa -P '' -P表示密码,-P '' 就表示空密码,也可以不用-P参数,这样就要三车回车,用-P就一次回车.它在/home/yaoy ...

  10. Linux WordPress博客的安装

    1:新建文件夹