springboot 總結

1、@bean

public User getUser(***@autowire*** User user){
return user
}
/在@bean 的狀態下,參數User面前自動加了@autowire 注入對象/

2、yml 文件注入bean 屬性

① 、
@compont
@Date
@ConfigurationProperties(prefix = ‘student’)
public class User{
}
②、
@Bean
@ConfigurationProperties(prefix = ‘student’)
public User getUser(){
return new User();
}

3、@PropertySource(value = “classpath:/db.properties”)

引入自己寫的配置文件

4、@ImportResource(value = {“calsspath:spring.xml”})

引入配置文件,比如ssm中的xml文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章