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);
}
}