问题
I was bashing my head to the wall (almost literally) trying to figure out why I was having this NullPointException problem for the past 17 days (now you believe, don't you ?).
So, reading and reading through Play's Documentation I have noticed something ( that I don't know how I haven't noticed before! ).
Configuring Ebean Play comes with the Ebean ORM. To enable it, add the Play Ebean plugin to your SBT plugins in project/plugins.sbt:
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.0")
Also, reading some posts at Play's forum, I have noticed that version 2.5.6
was released, and I was using version 2.5.4
, in any case I upgrade it both and it worked, it solved my NullPointerException
problem.
However, I have created a new project via Play's template:
activator new
Fetching the latest list of templates...
Browse the list of templates: http://lightbend.com/activator/templates
Choose from these featured templates or enter a template name:
1) minimal-akka-java-seed
2) minimal-akka-scala-seed
3) minimal-java
4) minimal-scala
5) play-java
6) play-scala
(hit tab to see a list of all templates)
> 5
Enter a name for your application (just press enter for 'play-java')
> a-new-project
OK, application "a-new-project" is being created using the "play-java" template.
To run "a-new-project" from the command line, "cd a-new-project" then:
/tmp/000/a-new-project/activator run
To run the test for "a-new-project" from the command line, "cd a-new-project" then:
/tmp/000/a-new-project/activator test
To run the Activator UI for "a-new-project" from the command line, "cd a-new-project" then:
/tmp/000/a-new-project/activator ui
Then checking project/plugins.sbt
file:
// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(PlayEbean).
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")
Which leads to my question: if you're starting a new project, via play's project template, why would you start with the oldest version of a plugin ? It would be better to start with the latest version of these plugins ?
You can see my changes on my repository here.
回答1:
Not a big deal. It is just that the template got outdated. The play-java
template is defined here:
https://github.com/playframework/playframework/tree/master/templates/play-java
And, you can see that the template is adding play-ebean plugin here:
https://github.com/playframework/playframework/blob/master/templates/play-java/project/plugins.sbt#L21
Unfortunately, the EBEAN_VERSION
variable was not updated, as you can see here:
https://github.com/playframework/playframework/blob/master/templates/build.sbt#L62
If you want, you can submit a (very small and specific) pull request to fix this.
Edit:
This pull request updates templates plugins: https://github.com/playframework/playframework/pull/6515
来源:https://stackoverflow.com/questions/39263538/why-play-framework-uses-old-ebean-version-in-the-new-project-templates