2017-03-27 10 views
2

私はPlayフレームワークを使ってウェブサイトを作っています。
しかし、プロパティファイルを読み込もうとしたときに問題がありました。
[Play.application().resourceAsStream("test.properties")]を検索してみましたが、エラー[Play.application().resourceAsStream("test.properties")]があります。Playフレームワーク2.5でプロパティファイルを読む方法

が、エラーが発生しました:

[the method aplication(Aplication) in the type Play is not applicable for the arguments()]

私は何をすべき?あなたはConfigurationオブジェクトを注入する必要がある

答えて

3

Scalaの

class HomeController @Inject()(conf: Configuration) extends Controller{ 

    def post() = Action{ 
    val testProp = conf.getString("test.properties") 
... 

のJava

public class HomeController extends Controller{ 

    @Inject 
    private Configuration configuration; 

    public Result post(){ 
    final String testProp = configuration.getString("test.properties") 
... 
+0

は、Javaコードを提供していただけますか? – saman

+0

私は答えを更新しました –

関連する問題