第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問關于在java spring中用@Autowired注解一個無參數的普通函數有什么作用?

請問關于在java spring中用@Autowired注解一個無參數的普通函數有什么作用?

達令說 2019-07-25 19:15:12
java spring中用@Autowired注解一個無參數的普通函數有什么作用?
查看完整描述

4 回答

?
HUX布斯

TA貢獻1876條經驗 獲得超6個贊

注解本身并沒有任何作用,編譯后只會留在二進制字節(jié)碼中,不會參與函數的執(zhí)行過程

@Autowired 注解是用來注入參數的,但是如果本身是無參的,也就代表沒有要注入的參數,其實應該是可以省略的,當然,上面的代碼也可以換一下:

1234 @Autowired  public void regFun(TplFun pubtranslate){      ModelBeanMap.put("pubtranslate", pubtranslate);  }

我不保證是正確的,理解意思就好


查看完整回答
反對 回復 2019-07-29
?
繁花如伊

TA貢獻2012條經驗 獲得超12個贊

這個是@Autowired 的定義

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
public @interface Autowired {

/**
* Declares whether the annotated dependency is required.
* <p>Defaults to <code>true</code>.
*/
boolean required() default true;

}

只可用在構造方法,字段,以及實例方法上;方法參數注入這個不知你是指哪鐘?

查看完整回答
反對 回復 2019-07-29
?
慕無忌1623718

TA貢獻1744條經驗 獲得超4個贊

public class TestController {     private final TestService1 test1;    private final TestService2 test2;    private final TestService3 test3;     @Autowired    public TestController(TestService1 test1, TestService2 test2, TestService3 test3) {        this.test1 = test1;        this.test2 = test2;        this.test3 = test3;    }}

查看完整回答
反對 回復 2019-07-29
  • 4 回答
  • 0 關注
  • 973 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號