大家,早安。我开始使用 vaadin 10,我正在尝试使用 Spring Jpa 在网格中设置项目,如下所示,但对我来说它标志着一个错误,这种情况不会发生在以前版本的 vaadin 中。
@HtmlImport("styles/shared-styles.html") @Route("") public class MainView extends VerticalLayout {
@Autowired
private UserService userService;
private Grid<User> grid = new Grid<>();
public MainView() {
grid.setItems(userService.selectAll());
add(grid);
}
我收到以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.portal.app.spring.MainView': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.portal.app.spring.MainView]: Constructor threw exception; nested exception is java.lang.NullPointerException
.....
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.portal.app.spring.MainView]: Constructor threw exception; nested exception is java.lang.NullPointerException at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:182) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1228) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] ... 72 common frames omitted Caused by: java.lang.NullPointerException: null
据我了解,这是由我的服务中的@autowire 引起的。
我希望有人与我分享我如何解决错误的想法,谢谢:)