时间:2021-05-20
创建一个简单的项目:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://ponentpublic class MyConsumer { @Reference private MyService myService; public void aaa() { myService.test(); }}启动类要引入配置文件:
import注解引入配置文件。
编写测试类测试:
@SpringBootTest(classes = ApplicationRun.class)@RunWith(SpringRunner.class)public class TestDemo { @Autowired public MyConsumer myConsumer; @Test public void fun1() { myConsumer.aaa(); }}以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
SpringBoot的自动装配装配了视图解析器了吗?我们可以看到SpringBoot自动装配的WebMvcAutoConfiguration类中,装配了以下关于
如果你想实现一些定制化功能,只需要写这个组件,然后将它交给springboot管理,springboot会给我们自动装配以下是spring官方文档解释由官方文档
SpringBoot自动装配最重要的注解@SpringBootApplication@Target(ElementType.TYPE)@Retention(Re
springboot常用注解如下: 1、ComponentScan。自动扫描组件,可自动发现和装配一些Bean。 2、Configuration。用于定制配
目录准备工作我们知道SpringBoot的自动装配的秘密在org.springframework.boot.autoconfigure包下的spring.fac