Я создал приложение Scala и Play Framework, и с ним я пытаюсь использовать библиотеку платежей Stripe. Но когда я использую я получаю ниже ошибки:Проблема с библиотекой платформ в Scala и Play
Compilation error
object stripe is not a member of package com
Я использую версии, как показано ниже,
- Scala Версия: 2.11.6
- SBT Версия: 0.13.8
Я использовал зависимость Stripe SBT в build.sbt
, как указано ниже,
"com.stripe" % "stripe-scala_2.9.1" % "1.1.2"
Мой build.sbt
файл, как показано ниже:
name := """My App Name"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
cache,
ws,
filters,
"com.typesafe.play" %% "play-mailer" % "3.0.1",
"com.typesafe.play" %% "play-slick" % "1.1.1",
"com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",
"postgresql" % "postgresql" % "9.1-901.jdbc4",
"commons-lang" % "commons-lang" % "2.6",
"com.stripe" % "stripe-scala_2.9.1" % "1.1.2"
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
Мой контроллер, где он дает исключение:
package controllers
import com.stripe
import com.stripe.{Charge, Customer}
import play.api.mvc._
/**
* Created by Nishan Patel on 28-04-2016.
*/
class PaymentController extends Controller {
def getPayment = Action { request =>
val formData = (request.body).asFormUrlEncoded
val stripe.apiKey = "sk_test_xxxxxxxxxxxxx";
val token = formData.get("stripeToken")(0)
val customerParams = Map("source" -> token, "description" -> "Customer Rollback Renew req.")
val customer = Customer.create(customerParams)
val chargeParams = Map("amount" -> 2000, "currency" -> "usd", "customer" -> customer.id)
Charge.create(chargeParams);
Ok
}
}
[error] missing or invalid dependency detected while loading class file 'package
.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definitio
n for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to s
ee the problematic classpath.)
[error] A full rebuild may help if 'package.class' was compiled against an incom
patible version of scala.
[error] missing or invalid dependency detected while loading class file 'APIReso
urce.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definitio
n for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to s
ee the problematic classpath.)
[error] A full rebuild may help if 'APIResource.class' was compiled against an i
ncompatible version of scala.
[error] missing or invalid dependency detected while loading class file 'Custome
r.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definitio
n for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to s
ee the problematic classpath.)
[error] A full rebuild may help if 'Customer.class' was compiled against an inco
mpatible version of scala.
[error] missing or invalid dependency detected while loading class file 'Charge.
class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definitio
n for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to s
ee the problematic classpath.)
[error] A full rebuild may help if 'Charge.class' was compiled against an incomp
atible version of scala.
[error] E:\Nishan\Confidential\My Workspace\MetaForce\app\controllers\PaymentCon
troller.scala:14: stable identifier required, but com.stripe.`package`.apiKey fo
und.
[error] val stripe.apiKey = "sk_test_xxxxxx";
[error] ^
[error] 5 errors found
[error] (compile:compileIncremental) Compilation failed
[error] application -
Все выглядит хорошо, но не знаю, почему я Я получаю эту проблему компиляции.
Мне кажется, что эта библиотека очень устарела, последняя обновляется в 2012 году. Кажется, это то, что вы хотели бы использовать: http://mvnrepository.com/artifact/com.stripe/stripe-java – childofsoong
To Расширьте это, посмотрите https://stripe.com/docs/libraries - похоже, что они не поддерживают отдельную библиотеку scala (и я понятия не имею, почему они будут). – childofsoong
@childofsoong Я тоже использовал это, но имел ту же проблему. Так что с java sbt plugin у меня тоже такая же проблема. – Nishan