Play Framework版本为2.4.6。加载网页时我有错误NoClassDefFoundError:play / api / cache / CachePlugin。我将scala版本从2.10.5更改为2.11.6。
java.lang.NoClassDefFoundError: play/api/cache/CachePlugin
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:760)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
java.net.URLClassLoader.access$100(URLClassLoader.java:73)
java.net.URLClassLoader$1.run(URLClassLoader.java:367)
java.net.URLClassLoader$1.run(URLClassLoader.java:361)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:360)
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
java.lang.ClassLoader.loadClass(ClassLoader.java:411)
java.lang.ClassLoader.loadClass(ClassLoader.java:411)
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:340)
play.utils.Reflect$.getClass(Reflect.scala:142)
play.api.Plugins$$anonfun$loadPlugins$1.apply(Plugins.scala:88)
play.api.Plugins$$anonfun$loadPlugins$1.apply(Plugins.scala:87)
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
scala.collection.immutable.List.foreach(List.scala:381)
scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
scala.collection.immutable.List.map(List.scala:285)
play.api.Plugins$.loadPlugins(Plugins.scala:87)
play.api.Plugins$$anonfun$apply$4.apply(Plugins.scala:100)
play.api.Plugins$$anonfun$apply$4.apply(Plugins.scala:100)
play.api.Plugins.thePlugins$lzycompute(Plugins.scala:59)
play.api.Plugins.thePlugins(Plugins.scala:59)
play.api.Plugins.length(Plugins.scala:60)
scala.collection.IndexedSeqLike$class.iterator(IndexedSeqLike.scala:90)
play.api.Plugins.iterator(Plugins.scala:57)
scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
play.api.Plugins.foreach(Plugins.scala:57)
play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:92)
play.api.Play$$anonfun$start$1.apply(Play.scala:87)
play.api.Play$$anonfun$start$1.apply(Play.scala:87)
play.utils.Threads$.withContextClassLoader(Threads.scala:21)
play.api.Play$.start(Play.scala:87)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:156)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:121)
scala.Option.map(Option.scala:146)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:121)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:119)
scala.util.Success.flatMap(Try.scala:230)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:119)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:111)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:902)
java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1689)
java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1644)
java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
** application.conf **
# This is the main configuration file for the application.
# ~~~~~
# Cache
play.modules.disabled+="play.api.cache.EhCacheModule"
play.cache.redis.bindCaches = ["db-cache", "user-cache", "session-cache"]
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
play.crypto.secret="</N_v`W4xv8GY^c7e=UCDYF]vXSguUvABIHoi[JNm1j@lf2C6S9TL[?FNM?ImDd;"
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# global=Global
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
#
# You can expose this datasource via JNDI if needed (Useful for JPA)
# db.default.jndiName=DefaultDS
# Evolutions
# ~~~~~
# You can disable evolutions if needed
evolutions=disabled
# Ebean configuration
# ~~~~~
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
#
ebean.default = "models.*"
#ebean.order = ["models.Order", "models.OrderItem"]
# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
# Root logger:
play.i18n.langs=["fr","en"]
# The public facing name of the site. Used when sending reset emails.
server.hostname="localhost:9000"
include "mail"
# Redis
redis.cache=enabled
redis.uri="redis://127.0.0.1:6379"
** build.sbt **
import sbt.Keys._
name := """app"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
jdbc,
"com.typesafe.play" %% "play" % "2.4.0" % "provided",
"com.typesafe.play" %% "play-cache" % "2.4.0",
"org.mindrot" % "jbcrypt" % "0.3m",
"com.typesafe.play" %% "play-mailer" % "3.0.1",
"org.sedis" %% "sedis" % "1.2.2",
"com.typesafe.play.modules" %% "play-modules-redis" % "2.4.0",
filters
)
resolvers ++= Seq(
"Apache" at "http://repo1.maven.org/maven2/",
"jBCrypt Repository" at "http://repo1.maven.org/maven2/org/"
)
resolvers += "sedis-fix" at "https://dl.bintray.com/graingert/maven/"
routesGenerator := InjectedRoutesGenerator
lazy val root = (project in file(".")).enablePlugins(play.PlayJava, PlayEbean)
fork in run := true