首页>代码>spring通过c-namespace的方式实现xml配置bean构造函数实例>/spring-c-namespace-xml-configuration-shortcut/src/main/java/com/memorynotfound/spring/Run.java
package com.memorynotfound.spring;

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

public class Run {

    public static void main(String... args){
        ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"app-config.xml"});

        // get bean with property
        CoffeeMachine coffeeMachine = context.getBean("coffeeMachine", CoffeeMachine.class);
        System.out.println(coffeeMachine);

        // get bean with c-namespace
        CoffeeMachine cCoffeeMachine = context.getBean("cCoffeeMachine", CoffeeMachine.class);
        System.out.println(cCoffeeMachine);

    }
}
最近下载更多
最近浏览更多
szf123  LV12 2023年5月30日
Canvcer  LV1 2023年3月1日
sleary  LV3 2021年5月4日
luyc123  LV6 2021年3月21日
xb1406112453  LV5 2021年2月27日
y20031217  LV8 2021年2月14日
a198036  LV2 2021年1月22日
未知错误  LV5 2021年1月20日
我们都是小怪兽  LV3 2021年1月19日
鸡毛飞上天  LV3 2021年1月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友