首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >资产已经定义为对象资产。

资产已经定义为对象资产。
EN

Stack Overflow用户
提问于 2013-04-02 11:03:39
回答 1查看 5.6K关注 0票数 6

我正在为Play子项目特性做更多的扩展测试,如下所述:http://www.playframework.com/documentation/2.0/SBTSubProjects。但我发现了错误:

代码语言:javascript
复制
Assets is already defined as object Assets

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

我已经为我的子项目定义了一个资产控制器,如下所述:资产控制器描述,甚至是主项目,但是错误不断出现。我的项目有什么问题?

控制器

代码语言:javascript
复制
package com.company.playstrap.controllers;

import controllers.AssetsBuilder;

public class Assets {

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

}

路由文件

代码语言:javascript
复制
# 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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-02 13:46:43

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

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

代码语言:javascript
复制
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)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15762484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档