gpt4 book ai didi

playframework - Assets 已定义为对象 Assets

转载 作者:行者123 更新时间:2023-12-04 15:00:35 31 4
gpt4 key购买 nike

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

Assets is already defined as object Assets

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

我已经为我的子项目定义了一个 Assets Controller ,如下所述: Asset Controller description ,即使对于主项目,但错误不断弹出。我的项目有什么问题?

Controller
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

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

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)

关于playframework - Assets 已定义为对象 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15762484/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com