2013-04-02 8 views
6

Ich mache erweiterte Tests für das Play Subproject Feature, wie hier beschrieben: http://www.playframework.com/documentation/2.0/SBTSubProjects. Aber ich bin immer die Fehlermeldung:Assets sind bereits als Objekt definiert Assets

Assets is already defined as object Assets 

Beispielanwendung auf GitHub: https://github.com/adis-me/PlayStrap

ich einen Asset-Controller für meine Teilprojekte definiert habe, wie hier beschrieben: Asset Controller description, auch für das Hauptprojekt, aber der Fehler hält Aufspringen. Was ist falsch an meinem Projekt?

-Controller

package com.company.playstrap.controllers; 

import controllers.AssetsBuilder; 

public class Assets { 

    public static controllers.AssetsBuilder delegate = new AssetsBuilder(); 

} 

Routen Datei

# Routes 
# This file defines all application routes (Higher priority routes first) 
# ~~~~ 

# Home page 
GET /        com.company.playstrap.controllers.Application.index() 

# Include sub projects 
-> /common        common.Routes 
-> /admin        admin.Routes 
-> /website        website.Routes 

# Map static resources from the /public folder to the /assets URL path 
GET  /assets/*file     com.company.playstrap.controllers.Assets.delegates.at(path="/public", file) 

Antwort

5

Es ist ein bekannter Fehler: https://groups.google.com/forum/#!msg/play-framework/2Zk5wjAlIng/Jcec1lt7AzQJ

Meine Abhilfe für eine eigene Admin-Modul:

package controllers.admin; 
import controllers.AssetsBuilder; 
import play.api.mvc.AnyContent; 
import play.api.mvc.Action; 
import play.mvc.*; 

public class Application extends Controller { 

    private static AssetsBuilder delegate = new AssetsBuilder(); 

    public static Action<AnyContent> asset(String path, String file) { 
     return delegate.at(path, file); 
    } 

} 

//routes file 
GET /assets/*file controllers.admin.Application.asset(path="/public", file) 
+0

Das bedeutet, dass alle (Reversed-Routing-Sachen) in Aussicht geschrieben werden muss wie: '@ routes.Assets.asset (" someAss ")'? Ist dieser Fehler behoben, kann ich keinen Fehlerbericht für dieses Problem finden ... – adis

1

Ich hatte dieses Problem letzte Woche, als ich versuchte, die Assets-Klasse als Java-Klasse zu schreiben. Ich konnte die Kompilation Problem Schreiben der Assets Klasse in meinem Submodul als Scala-Klasse, die gleiche Art und Weise lösen, wie sie auf die Dokumentation beschrieben: http://www.playframework.com/documentation/2.1.1/SBTSubProjects

Grundsätzlich Struktur meines Projekts ist:

MyApplication 
    | - app 
    | - conf 
    | - modules 
     | - admin 
      | - app 
       | - controllers 
        | - admin 
         | - Assets.scala 
    | - project 
    | - public 


Assets.scala Inhalt:

package controllers.contabil 

object Assets extends controllers.AssetsBuilder 


Und schließlich der Inhalt meiner admin.routes Datei ist:

GET  /assets/*file controllers.admin.Assets.at(path="/public", file) 

# Home page 
GET  /index   controllers.admin.Application.index() 


Prost