zhaoyongqi

spring注入对象

1.@Autowired

 

 

package com.zyq.pi.common.cache;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class DefaultCacheTest {
	@Autowired//先按类型注入,再按名字注入. 如果用@Qualifier指定了名字或者类型则不采取默认的方式,而采用@Qualifier指定的方式注入
	@Qualifier("weakCache")
	private Cache deCache;

    @Test
    public void testCache() {
    	System.out.println(deCache);
    }

}

  

发表于 2020-07-29 10:05  905413993  阅读(0)  评论(0编辑  收藏
 

分类:

spring

技术点:

相关文章:

  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
猜你喜欢
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-09-19
相关资源
相似解决方案