资产已经定义为对象资产

资产已经定义为对象资产

本文介绍了资产已经定义为对象资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对Play子项目功能进行更多扩展测试,如下所述: http://www. playframework.com/documentation/2.0/SBTSubProjects .但是我得到了错误:

I am doing more extended tests for Play Subproject feature as described here: http://www.playframework.com/documentation/2.0/SBTSubProjects. But I am getting the error:

Assets is already defined as object Assets

托管在github上的示例应用程序: https://github.com/adis-me/PlayStrap

Sample application hosted on github: https://github.com/adis-me/PlayStrap

我已经为子项目定义了一个资产控制器,如下所述:资产控制器说明,即使对于主项目也是如此,但错误不断出现.我的项目怎么了?

I have defined an Asset controller for my subprojects as described here: Asset Controller description, even for the main project, but the error keeps popping up. What is wrong with my project?

控制器

package com.company.playstrap.controllers;

import controllers.AssetsBuilder;

public class Assets {

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

}

路由文件

# 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)

推荐答案

这是一个已知的错误: https://groups.google.com/forum/#!msg/play-framework/2Zk5wjAlIng/Jcec1lt7AzQJ

It is a known bug: https://groups.google.com/forum/#!msg/play-framework/2Zk5wjAlIng/Jcec1lt7AzQJ

我自己的管理模块的解决方法:

My workaround for an own admin module:

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)

这篇关于资产已经定义为对象资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 07:59