SpringBoot 01: JavaConfig + @ImportResource + @PropertyResource( 二 )

测试代码package com.example.springboot.testspringconfig;import com.example.springboot.configuration.SpringConfig;import com.example.springboot.model.JiaoZi;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class TestSpringConfig {@Testpublic void testPropertiesSource(){ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);JiaoZi jiaoZi = (JiaoZi) applicationContext.getBean("jiaozi");System.out.println("food: " + jiaoZi);}}

推荐阅读