有没有人知道使用Play框架和SLICK(ScalaQuery)的好教程或示例项目(github)?我正在努力让他们一起工作.
我收到此错误:
[info] play - Application started (Dev)
[error] application -
! @6b13oi41c - Internal server error, for request [GET /listBooks] ->
play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NoClassDefFoundError: Could not initialize class scala.slick.ast.opt.Relational$]]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1-2.0.2.jar:2.0.2]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1-2.0.2.jar:2.0.2]
at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor-2.0.2.jar:2.0.2]
at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1-2.0.2.jar:2.0.2]
at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor-2.0.2.jar:2.0.2]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor-2.0.2.jar:2.0.2]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class scala.slick.ast.opt.Relational$
at scala.slick.driver.BasicProfile$class.processAST(BasicProfile.scala:18) ~[slick_2.10.0-M4-0.10.0-M2.jar:0.10.0-M2]
at scala.slick.driver.PostgresDriver$.processAST(PostgresDriver.scala:69) ~[slick_2.10.0-M4-0.10.0-M2.jar:0.10.0-M2]
at scala.slick.driver.BasicProfile$class.createQueryBuilder(BasicProfile.scala:22) ~[slick_2.10.0-M4-0.10.0-M2.jar:0.10.0-M2]
at scala.slick.driver.PostgresDriver$.createQueryBuilder(PostgresDriver.scala:69) ~[slick_2.10.0-M4-0.10.0-M2.jar:0.10.0-M2]
at scala.slick.driver.BasicProfile$class.buildSelectStatement(BasicProfile.scala:23) ~[slick_2.10.0-M4-0.10.0-M2.jar:0.10.0-M2]
at scala.slick.driver.PostgresDriver$.buildSelectStatement(PostgresDriver.scala:69) ~[slick_2.10.0-M4-0.10.0-M2.jar:0.10.0-M2]
[error] application -
Run Code Online (Sandbox Code Playgroud)
这是我的书模型:
package …Run Code Online (Sandbox Code Playgroud) 我遇到了我的Spring控制器问题 - 我没有找到默认的构造函数 - 但是他们确实有一个我试图通过applicationContext.xml创建的构造函数 - 以下是相关的一点:
<bean id="PcrfSimulator" class="com.rory.services.pcrf.simulator.PcrfSimulator" init-method="start">
</bean>
<bean id="CacheHandler" class="com.rory.services.pcrf.simulator.handlers.CacheHandler">
<constructor-arg index="0" type="com.rory.services.pcrf.simulator.CustomGxSessionIdCacheImpl">
<bean factory-bean="PcrfSimulator" factory-method="getGxSessionIdCache">
</bean>
</constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)
IE浏览器.我首先创建一个bean,然后尝试将该bean的方法调用结果传递给第二个bean的(CacheHandler)构造函数.
这是CacheHandler的开始:
@Controller
public class CacheHandler {
private final CustomGxSessionIdCacheImpl gxSessionIdCache;
public CacheHandler(CustomGxSessionIdCacheImpl gxSessionIdCache) {
this.gxSessionIdCache = gxSessionIdCache;
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheHandler' defined in URL [jar:file:/users/rtorney/Documents/apache-tomcat-7.0.25/webapps/PCRFSimulator-4.0/WEB-INF/lib/PCRFSimulator-4.0.jar!/com/rory/services/pcrf/simulator/handlers/CacheHandler.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.rory.services.pcrf.simulator.handlers.CacheHandler]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.rory.services.pcrf.simulator.handlers.CacheHandler.<init>()
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢!
我正在尝试使用sbt-web和sbt-js-engine特别是用npm而不是webjars来解析我的依赖关系.
我的问题是target/web/public/main/lib在web-stage任务期间不会将依赖项复制到文件夹中,因为使用webjar就是这种情况.
我使用sbt-js-engine的示例项目进行测试.有了这个项目,我希望console-browserify从package.json文件target/web/public/main/lib夹中的文件中找到依赖项,但事实并非如此.

也许我完全误解了什么?
我知道一个方法可以有这样的代码:
def m(p1:Int => Int) ...
Run Code Online (Sandbox Code Playgroud)
这意味着此方法采用返回Int的函数p1
但是在浏览Play的同时!框架代码我找到了一个具有难以理解的方法的特征:
trait Secured {
def username(request: RequestHeader) = request.session.get(Security.username)
def onUnauthorized(request: RequestHeader) = Results.Redirect(routes.Auth.login)
def withAuth(f: => String => Request[AnyContent] => Result) = {
Security.Authenticated(username, onUnauthorized) { user =>
Action(request => f(user)(request))
}
}
/**
* This method shows how you could wrap the withAuth method to also fetch your user
* You will need to implement UserDAO.findOneByUsername
*/
def withUser(f: User => Request[AnyContent] => Result) = withAuth { username => implicit request …Run Code Online (Sandbox Code Playgroud) 我已经开始使用Play和Play-ReactiveMongo插件,并在GET"document by id"场景中测试404响应.不幸的是,而不是Play返回404 NotFound响应,我得到了这个异常:
java.util.NoSuchElementException: JsError.get
at play.api.libs.json.JsError.get(JsResult.scala:11) ~[play_2.10.jar:2.1.1]
at play.api.libs.json.JsError.get(JsResult.scala:10) ~[play_2.10.jar:2.1.1]
at play.modules.reactivemongo.json.collection.JSONGenericHandlers$StructureBufferWriter$.write(jsoncollection.scala:44) ~[play2-reactivemongo_2.10-0.9.jar:0.9]
at play.modules.reactivemongo.json.collection.JSONGenericHandlers$StructureBufferWriter$.write(jsoncollection.scala:42) ~[play2-reactivemongo_2.10-0.9.jar:0.9]
at reactivemongo.api.collections.GenericQueryBuilder$class.reactivemongo$api$collections$GenericQueryBuilder$$write(genericcollection.scala:323) ~[reactivemongo_2.10-0.9.jar:0.9]
at reactivemongo.api.collections.GenericQueryBuilder$class.cursor(genericcollection.scala:333) ~[reactivemongo_2.10-0.9.jar:0.9]
Run Code Online (Sandbox Code Playgroud)
如果id参数与现有文档匹配,则下面的getById函数成功返回单个文档,如果找不到文档,则在"one [JsValue]"行上成功返回异常.
路线文件:
GET /items/:id controllers.ItemsController.getById(id: String)
Run Code Online (Sandbox Code Playgroud)
控制器对象:
object ItemsController extends Controller with MongoController {
def itemsCollection: JSONCollection = db.collection[JSONCollection]("items")
def getById(id: String) = Action {
Async {
val query = Json.obj("_id" -> Json.obj("$oid" ->id))
val futureItem = itemsCollection.
find(query).
one[JsValue]
futureItem.map {
case Some(item) => Ok(item)
case None => NotFound(Json.obj("message" -> …Run Code Online (Sandbox Code Playgroud) 根据这些 文章,Websocket的成功率仅为63%(如果你有一个支持websocket的浏览器).
这篇InfoQ文章(http://www.infoq.com/articles/Web-Sockets-Proxy-Servers)表示,您有更好的机会使用安全Websockets(wss://)进行连接.
有没有人对企业就绪应用程序使用Websockets,企业代理和防火墙背后有任何反馈?
如果我的问题不在话题,我很抱歉.
此致,尼科
免责声明:我对Gradle很新.
我正在尝试使用Gradle(1.0-rc1)构建我的项目,使用来自Maven artefact的Snapshot依赖项.
但是当我尝试使用解决依赖关系时gradle --info dependencies,我收到以下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dependencies'.
> Could not resolve all dependencies for configuration ':compile'.
> Could not resolve group:com.l2fprod, module:l2fprod-common-all, version:7.3.
Required by:
:test:unspecified > org.valkyriercp:valkyrie-rcp-core:1.1-SNAPSHOT
> Could not HEAD 'https://raw.github.com/Ekito/maven-repo/master/ \
snapshots/com/l2fprod/l2fprod-common-all/7.3/l2fprod-common-all-7.3.jar'.
> Could not resolve group:org.valkyriercp, module:valkyrie-rcp-resources,
version:1.1-SNAPSHOT.
Required by:
:test:unspecified > org.valkyriercp:valkyrie-rcp-core:1.1-SNAPSHOT
> Could not resolve group:org.valkyriercp, module:valkyrie-rcp,
version:1.1-SNAPSHOT.
> Could not HEAD 'https://raw.github.com/Ekito/maven-repo/master/ \
snapshots/org/valkyriercp/valkyrie-rcp/1.1-SNAPSHOT \
/valkyrie-rcp-1.1-SNAPSHOT.jar'.
Run Code Online (Sandbox Code Playgroud)
但Maven …
我试图通过cookie管理我的用户.这并不容易,因为绝对没有关于这个主题的文档.
在样本"zentask"的帮助下,我做了这个:
session("username", filledForm.field("username").value());
public class Secured{
public static Session getSession() {
return Context.current().session();
}
public static String getUsername() {
return getSession().get("username");
}
public static boolean isAuthorized() throws Exception {
String username = getUsername();
if (username == null)
return false;
long userCount = DatabaseConnect.getInstance().getDatastore()
.createQuery(User.class).field("username").equal(username)
.countAll();
if (userCount == 1)
return true;
return false;
}
Run Code Online (Sandbox Code Playgroud)
我这样使用它:
public static Result blank() throws Exception {
if (Secured.isAuthorized())
return ok(Secured.getUsername());
else
return ok(views.html.login.form.render(loginForm));
}
Run Code Online (Sandbox Code Playgroud)
现在我有几个问题/问题:
1.)Cookie不是dectypted,看起来总是一样.例如bdb7f592f9d54837995f816498c0474031d44c1a-username%3Akantaki
2.)Security.Authenticator类有什么作用?
3.)我认为通过cookie进行用户管理是一个非常普遍的问题,确实可以玩!2.0为我提供了完整的解决方案吗?或者至少有一些文件?
我正在尝试将库从 Scala 2.13 迁移到 Scala 3,但现有代码无法编译。
这是一个片段
trait Identity
trait Authenticator
trait Env {
type I <: Identity
type A <: Authenticator
}
trait IdentityService[T <: Identity]
trait AuthenticatorService[T <: Authenticator]
trait Environment[E <: Env] {
def identityService[T <: Identity]: IdentityService[E#I]
def authenticatorService: AuthenticatorService[E#A]
}
Run Code Online (Sandbox Code Playgroud)
Scala 3 编译器失败并显示:
error] 14 | def identityService[T <: Identity]: IdentityService[E#I]
[error] | ^
[error] | E is not a legal path
[error] | since it is not a concrete type
[error] -- Error:
[error] …Run Code Online (Sandbox Code Playgroud) 我create在Play中有一个动作!框架控制器,应返回HTTP状态代码Created并将客户端重定向到创建的对象的位置.
public class SomeController extends Controller {
public static void create() {
Something something = new Something();
something.save();
response.status = StatusCode.CREATED; // Doesn't work!
show(something.id);
}
public static void show(long id) {
render(Something.findById(id));
}
}
Run Code Online (Sandbox Code Playgroud)
另请参阅Play中的方法链接!框架文档.
上面的代码返回状态代码302 Found而不是201 Created.我该怎么做让Play返回正确的状态(和Location标题)?
scala ×4
java ×3
build.gradle ×1
cookies ×1
dependencies ×1
gradle ×1
maven ×1
mongodb ×1
proxy ×1
rest ×1
sbt-web ×1
scala-3 ×1
scalaquery ×1
spring ×1
spring-mvc ×1
web.xml ×1
websocket ×1