1
当我尝试Spring-Dependency-Injection
在PlayFramework
与Java 8
整合,我得到以下错误,当使用play clean compile
命令PlayFramework:集成春天依赖注入PlayFramework
------
value findUserById is not a member of com.harmeetsingh13.controllers.UserController
[error] GET/@com.harmeetsingh13.controllers.UserController.findUserById(userId:Integer)
-------
以下是我的配置和代码
编译代码public class GlobalConfiguration extends GlobalSettings{
private AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
@Override
public void onStart(Application app) {
super.onStart(app);
// AnnotationConfigApplicationContext can only be refreshed once, but we do it here even though this method
// can be called multiple times. The reason for doing during startup is so that the Play configuration is
// entirely available to this application context.
applicationContext.scan("com.harmeetsingh13");
applicationContext.refresh();
// This will construct the beans and call any construction lifecycle methods e.g. @PostConstruct
applicationContext.start();
}
@Override
public void onStop(Application app) {
// This will call any destruction lifecycle methods and then release the beans e.g. @PreDestroy
applicationContext.close();
super.onStop(app);
}
@Override
public <A> A getControllerInstance(Class<A> clazz) throws Exception {
return applicationContext.getBean(clazz);
}
}
我Coltroller:
@Named
@Singleton
public class UserController extends Controller{
public static Result findUserById(Integer userId) {
/*Optional<User> user = userService.findUserById(userId);
if(user.isPresent()){
}*/
return null;
}
}
我的路由文件如下:
Routes
# Home page
GET/@com.harmeetsingh13.controllers.UserController.findUserById(userId:Integer)