目的:

    实现在配置文件中,进行组装

 

1、Properties文件配置如下:

dns=http://211.103.227.133:8080

qrcode=${dns}/wx/views/invite/register.html

类似域名和公共的东西,希望在properties文件中直接进行组装,而不是在代码中进行组装

2、使用spring注解 @Value注解

 

 

 

注意:图中使用@Service或 @Component,并且@Value必须写在set属性上,否则取不到值

   因为定义的qr_code是static  ; 如果是非static变量,则可以取到值

 

输出结果为:

       http://211.103.227.133:8080/wx/views/invite/register.html

 

posted on 2017-06-30 21:03  jwrwst  阅读(372)  评论(0编辑  收藏  举报