JavaconfigApplicationTests

package com.example.demo;

import com.example.demo.config.JavaConfig;
import com.example.demo.model.Printer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class JavaconfigApplicationTests {

        @Test
        public void contextLoads() {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(JavaConfig.class);
        Printer printer = context.getBean(Printer.class);
        printer.print();
        context.close();
        }

}
 
 
package com.example.demo.model;

/**
 * Created by Administrator on 2017/12/25.
 */
public class ColorInk {
    public void getColor(){
        System.out.println("我是红色");
    }
}

 
posted @ 2022-12-15 16:39  cnetsa  阅读(21)  评论(0编辑  收藏  举报