![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
spring
Huan03250
分享也是一种学习
展开
-
@Autowired和@Resource的使用
一. @Autowired注解 源码: Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented pub...原创 2019-05-12 21:17:24 · 883 阅读 · 0 评论 -
@Value注解读取属性的两种方式
我们平时在SpringMvc和SpringBoot中常常涉及到一些自定义属性的注入,尤其是在SpringBoot中,我们常常将一些配置属性配置到yml文件中,相对于SpringBoot是有注解和自己写set方法注入属性的方法,对于属性比较多的情况,注解方式会使代码阅读性变差和代码臃肿,那时候可以自己写bean通过set注入,但是我们也经常使用@Value,所以这里针对MVC方式提供两种方式,读取p...原创 2019-05-12 22:05:56 · 6938 阅读 · 0 评论