小编Rod*_*mez的帖子

为什么错误冲突的跨版本后缀?

当我尝试在sbt中编译Scala项目时,我收到此错误.

Modules were resolved with conflicting cross-version suffixes in {file:/home/seven3n/caja/Flujo_de_caja/}flujo_de_caja:
[error]    com.typesafe.akka:akka-actor _2.11, _2.10
[error]    org.scalaz:scalaz-effect _2.10, _2.11
[error]    org.scalaz:scalaz-core _2.10, _2.11
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: com.typesafe.akka:akka-actor, org.scalaz:scalaz-effect, org.scalaz:scalaz-core
Run Code Online (Sandbox Code Playgroud)

这是我的build.sbt文件:

scalaVersion := "2.11.0"

resolvers ++= Seq(
  "Sonatype snapshots repository" at "https://oss.sonatype.org/content/repositories/snapshots/",
  "Spray repository" at "http://repo.spray.io/",
  "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

libraryDependencies ++= {
  val akkaVersion = "2.3.2"
  val sprayVersion = "1.3.1-20140423"
  val sprayJsonVersion = "1.2.6" …
Run Code Online (Sandbox Code Playgroud)

scala sbt akka spray

36
推荐指数
3
解决办法
2万
查看次数

没有在亚马逊ec2微实例上工作

我正在尝试在亚马逊ec2微实例上使用sbt,但是当我执行sbt命令时我遇到了这个错误.

mkdir prueba
cd prueba
sbt

There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (malloc) failed to allocate 715849728 bytes for committing reserved memory
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

先感谢您!

openjdk scala amazon-ec2 amazon-web-services sbt

6
推荐指数
2
解决办法
1826
查看次数

为什么authenticate指令会导致"错误:类型不匹配"?

我的喷涂项目中出现了这个错误.

Error:(41, 28) type mismatch;
 found   : spray.routing.authentication.ContextAuthenticator[co.s4n.authentication.entities.Usuario]
    (which expands to)  spray.routing.RequestContext => scala.concurrent.Future[scala.util.Either[spray.routing.Rejection,co.s4n.authentication.entities.Usuario]]
 required: spray.routing.directives.AuthMagnet[?]
              authenticate(validateToken) {
                           ^
Run Code Online (Sandbox Code Playgroud)

这是我的TokenValidator特征

trait TokenValidator {

  def validateToken: ContextAuthenticator[Usuario] = {
    ctx =>
      val header = ctx.request.headers.find(_.name == "Access_Token")
      if (header isDefined) {
        doAuth(header.get)
      }
      else {
        Future(Left(AuthenticationFailedRejection(AuthenticationFailedRejection.CredentialsMissing, List())))
      }
  }

  def doAuth(header: HttpHeader): Future[Authentication[Usuario]] = {
    Dao.validateToken(header.value).map {
      case Some(usuario) => Right(usuario)
      case None => Left(AuthenticationFailedRejection(AuthenticationFailedRejection.CredentialsRejected, List()))
    }
  }


}
Run Code Online (Sandbox Code Playgroud)

这就是我遇到错误的地方

//@DELETE
  //localhost:9090/authenticacion/users/{{userEmail}}
  val `users/{{email}}` =
    pathPrefix(`path-prefix`) {
      pathPrefix(`users-path-prefix` / Segment) { …
Run Code Online (Sandbox Code Playgroud)

spray

4
推荐指数
1
解决办法
1321
查看次数

功能编程设置器

我怎么能在这样的函数式编程中做一个setter?我想尊重不变性和其他函数式编程原理.

private int age;

public void setAge(int age){

this.age=age;

}
Run Code Online (Sandbox Code Playgroud)

那可能吗?如果没有,我如何用函数式编程语言表示程序的状态(及其变化)?

setter functional-programming scala

3
推荐指数
1
解决办法
426
查看次数

如何使用authenticate指令执行基于令牌的身份验证?

我正在进行基于令牌的身份验证,我不知道我应该如何authenticate在我的路由中使用指令:

access_token从标题中得到了.

post {
  headerValueByName("Access_Token") {
    access_token => {
      authenticate(??????){
        user => {
          ......
          ......
       }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我该如何进行身份验证?

access-token spray

3
推荐指数
1
解决办法
4140
查看次数

在控制器中初始化ng-model时,不会触发Angularjs选择ng-change

我有这样的选择

<select ng-model="id_select" ng-options="fide.id as fide.name for fide in fides" ng-change="loadInfo()">
   <option value="" selected disabled>Seleccionar</option>
</select>
Run Code Online (Sandbox Code Playgroud)

在我的控制器中,我有这个

RestService.getFides().then(function(fides){

   $scope.id_select = fides;
   if(typeof $rootScope.selected_id !== 'undefined')
   {
      $scope.id_select = $rootScope.selected_id
   }
});

$scope.loadInfo = function() {
  alert("triggered!!");
}
Run Code Online (Sandbox Code Playgroud)

我的选择是按预期加载fides但是当我尝试使用$ rootScope的值设置我的选择值时,ng-change函数不会触发loadInfo()但是当我在视图中选择它时它工作正常.

我有什么不对的想法吗?

提前谢谢你的帮助:)

angularjs angularjs-ng-change

3
推荐指数
1
解决办法
1万
查看次数

在scala特征中实例化val是正确的吗?

我在喷雾,akka,scala,reactivemongo项目工作,我有这个特点

trait PersistenceManager {

  val driver = new MongoDriver
  val connection = driver.connection(List("localhost"))

  def loan[A](collectionName: String)(f: BSONCollection => Future[A]): Future[A] = {
    val db = connection("flujo_caja_db")
    val collection = db.collection(collectionName)
    f(collection)
  }
}
Run Code Online (Sandbox Code Playgroud)

我也有Dao的对象使用这样的特性:

object Dao extends PersistenceManager {

   def find = loan("users"){
     collection =>
          collection.find(BsonDocument())....
   }

}
Run Code Online (Sandbox Code Playgroud)

在我的持久性管理器特征中实现这些数据库val是正确的吗?它的效果非常好.

谢谢!

scala reactivemongo

1
推荐指数
1
解决办法
161
查看次数