springboot--は、設定ファイルを読み込み

config.name = confignameは
config.password = configpassword
@Configuration 
@ConfigurationProperties(接頭辞= "設定")
@PropertySource( "クラスパス:/config.properties")
publicクラスコンフィグ{ 
    プライベート文字列名; 

    プライベート文字列のパスワード。

    パブリック文字列のgetName(){ 
        名前を返します。
    } 

    公共ボイドのsetName(文字列名){ 
        this.name =名。
    } 

    パブリック文字列getPasswordに(){ 
        戻りパスワード。
    } 

    公共ボイドするsetPassword(文字列のパスワード){ 
        this.password =パスワード。
    } 
}

 @EnableConfigurationProperties({Config.class})  
への直接注射を用い
@Autowired
コンフィグ設定。

 

 

@ComponentScans({@ ComponentScan( "com.dx.controller")、@ComponentScan( "App.configファイル")})

おすすめ

転載: www.cnblogs.com/jentary/p/11038564.html