Spring6.0官方文档示例:(26)配置文件中beans配置的default-init-method优先级低于bean上配置的init-method

package cn.edu.tju.service;

public class BeerService {
    public void defaultInit(){
        System.out.println("default init method......");
    }

    public void myInitMethod(){
        System.out.println("my init method......");
    }
}








package cn.edu.tju.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestInit {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        context.getBean("beerService");
    }
}

输出:Spring6.0官方文档示例:(26)配置文件中beans配置的default-init-method优先级低于bean上配置的init-method_第1张图片

你可能感兴趣的:(Spring,java,开发语言)