zoukankan      html  css  js  c++  java
  • spring随手笔记2:初始化方法

    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";
        }
    
    }
  • 相关阅读:
    结对编程
    四则运算
    认清自我,创造未来!!!
    浅谈GIT
    典型用户及用例故事
    结对编程 四则运算
    四则运算
    《未来的程序员》
    java项目命名规范
    四则运算测试
  • 原文地址:https://www.cnblogs.com/ltflike/p/3989016.html
Copyright © 2011-2022 走看看