您好,我正在尝试使用 Play 在 Web 应用程序中运行一个简单的测试!框架,但我得到一个错误:
[info] RouteTest
[error] Test RouteTest.testRouteActivityIndex failed: DataSource user is null?
[error] at com.avaje.ebeaninternal.server.lib.sql.DataSourcePool.<init>(DataSourcePool.java:198)
[error] at com.avaje.ebeaninternal.server.lib.sql.DataSourceManager.getDataSource(DataSourceManager.java:210)
[error] at com.avaje.ebeaninternal.server.lib.sql.DataSourceGlobalManager.getDataSource(DataSourceGlobalManager.java:63)
[error] at com.avaje.ebeaninternal.server.core.DefaultServerFactory.getDataSourceFromConfig(DefaultServerFactory.java:427)
[error] at com.avaje.ebeaninternal.server.core.DefaultServerFactory.setDataSource(DefaultServerFactory.java:388)
[error] at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:168)
[error] at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:125)
[error] at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)
[error] at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:64)
[error] at com.avaje.ebean.Ebean$ServerManager.getWithCreate(Ebean.java:237)
[error] at com.avaje.ebean.Ebean$ServerManager.get(Ebean.java:224)
[error] at com.avaje.ebean.Ebean$ServerManager.access$200(Ebean.java:159)
[error] at com.avaje.ebean.Ebean.getServer(Ebean.java:288)
[error] at play.db.ebean.Model$Finder.server(Model.java:216)
[error] at play.db.ebean.Model$Finder.all(Model.java:230)
[error] at models.Activity.all(Activity.java:29)
[error] at controllers.Application.activities(Application.java:18)
[error] at Routes$$anonfun$routes$1$$anonfun$apply$5$$anonfun$apply$6.apply(routes_routing.scala:60)
[error] at Routes$$anonfun$routes$1$$anonfun$apply$5$$anonfun$apply$6.apply(routes_routing.scala:60)
[error] at play.core.Router$HandlerInvoker$$anon$4$$anon$1.invocation(Router.scala:1086)
[error] at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:33)
[error] at play.core.j.JavaAction$class.apply(JavaAction.scala:74)
[error] at play.core.Router$HandlerInvoker$$anon$4$$anon$1.apply(Router.scala:1085)
[error] at play.test.Helpers.invokeHandler(Helpers.java:34)
[error] at play.test.Helpers.routeAndCall(Helpers.java:246)
[error] at play.test.Helpers.routeAndCall(Helpers.java:231)
[error] at RouteTest.testRouteActivityIndex(RouteTest.java:14)
[error] ...
[info] x RouteTest.testRouteActivityIndex
测试代码如下:
@Test
public void testRouteActivityIndex(){
Result result = routeAndCall(fakeRequest(GET, "/activities"));
Assert.assertNotNull(result);
}
我试着研究这个错误,但没有发现任何对这种情况非常有用的东西,甚至是网站的 play!。有人经历过这个吗?