我在springdate+jsf上做项目。我有一个奇怪的error:all methods crud存储库的返回null。
模型.game.java
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "Игры")
public class Game
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "Название")
private String name;
@Column(name = "Бюджет")
private int budget;
@Column(name = "Прибыль")
private int profit;
@Column(name = "Оценка")
private int number;
@Column(name = "Платформа")
private int platform;
@Column(name = "Статус разработки")
private int status;
@Column(name = "Начало разработки")
private Date start;
@Column(name = "Дата релиза")
private Date end;
public void update(Game new_game)
{
this.name = new_game.name;
this.budget = new_game.budget;
this.profit = new_game.profit;
this.number = new_game.number;
this.platform = new_game.platform;
this.status = new_game.status;
this.start = new_game.start;
this.end = new_game.end;
}
}
存储库.gamesrepository
public interface GamesRepository extends CrudRepository<Game, Long>
{
Game findByName(String nameGame);
List<Game> getAllBy();
}
服务.gamesservice
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Service
public class GamesService
{
@Autowired
private GamesRepository addressRepository;
public void addBank(Game game) {
Game savedBank = addressRepository.save(game);
}
public void delete(Game game) {
addressRepository.delete(game);
}
public Game getByName(String name) {
return addressRepository.findByName(name);
}
public Game editBank(Game game) {
return addressRepository.save(game);
}
public Game getAll()
{
return addressRepository.findByName("Geoffrey");
}
}
查看.游戏
@Component(value = "games")
@SessionScope
public class Games {
@Autowired
private GamesService gamesService;
private List<Game> All_games = new ArrayList<Game>();
public Games()
{
//List<Game> t=gamesService.getAll();
// System.out.println("Размер"+t.size());
try {
All_games.addAll(gamesService.getAll());
} catch (Exception e) {
e.printStackTrace();
}
All_games.add(new Game());
}
public void onRowEdit(RowEditEvent event) {
Game new_game=(Game)event.getObject();
All_games.get(new_game.getId()-1).update(new_game);
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO", "X/Y edit successful!");
FacesContext.getCurrentInstance().addMessage(null, msg);
int i=0;
i++;
}
public List<Game> getAll_games() {
return All_games;
}
public void setAll_games(List<Game> all_games) {
All_games = all_games;
}
}
错误:
2020-12-31 21:55:00.139 ERROR 5624 --- [nio-8080-exec-1] j.e.r.webcontainer.jsf.application : Error Rendering View[/ui/hello.xhtml]
javax.el.ELException: /ui/hello.xhtml @34,95 value="#{games.all_games}": Error reading [all_games] on type [org.xtremebiker.jsfspring.view.Games$$EnhancerBySpringCGLIB$$35b9b860]
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:119) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:200) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:187) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIData.getValue(UIData.java:766) ~[javax.faces-2.3.5.jar:2.3.5]
at org.primefaces.component.api.UIData.getDataModel(UIData.java:792) ~[primefaces-7.0.jar:7.0]
at javax.faces.component.UIData.getRowCount(UIData.java:371) ~[javax.faces-2.3.5.jar:2.3.5]
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:1141) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:1120) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:445) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:376) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:95) ~[primefaces-7.0.jar:7.0]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671) ~[javax.faces-2.3.5.jar:2.3.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
Caused by: javax.el.ELException: Error reading [all_games] on type [org.xtremebiker.jsfspring.view.Games$$EnhancerBySpringCGLIB$$35b9b860]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:98) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:180) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:208) ~[javax.faces-2.3.5.jar:2.3.5]
at org.apache.el.parser.AstValue.getValue(AstValue.java:169) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:115) ~[javax.faces-2.3.5.jar:2.3.5]
... 60 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.games' defined in file [F:\Intelij\demo (3)\demo\target\classes\org\xtremebiker\jsfspring\view\Games.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.xtremebiker.jsfspring.view.Games]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1238) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1137) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:353) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:45) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.context.request.SessionScope.get(SessionScope.java:57) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:350) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[spring-aop-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:672) ~[spring-aop-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.xtremebiker.jsfspring.view.Games$$EnhancerBySpringCGLIB$$35b9b860.getAll_games(<generated>) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:94) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
... 65 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.xtremebiker.jsfspring.view.Games]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:182) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1230) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 81 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.xtremebiker.jsfspring.view.Games.<init>(Games.java:33) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:170) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 83 common frames omitted
2020-12-31 21:55:00.146 ERROR 5624 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[facesServlet] : Servlet.service() for servlet [facesServlet] in context with path [] threw exception [Error creating bean with name 'scopedTarget.games' defined in file [F:\Intelij\demo (3)\demo\target\classes\org\xtremebiker\jsfspring\view\Games.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.xtremebiker.jsfspring.view.Games]: Constructor threw exception; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at org.xtremebiker.jsfspring.view.Games.<init>(Games.java:33) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:170) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1230) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1137) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:353) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:45) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.context.request.SessionScope.get(SessionScope.java:57) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:350) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[spring-aop-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:672) ~[spring-aop-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.xtremebiker.jsfspring.view.Games$$EnhancerBySpringCGLIB$$35b9b860.getAll_games(<generated>) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:94) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:180) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:208) ~[javax.faces-2.3.5.jar:2.3.5]
at org.apache.el.parser.AstValue.getValue(AstValue.java:169) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190) ~[tomcat-embed-el-8.5.31.jar:8.5.31]
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:115) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:200) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:187) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIData.getValue(UIData.java:766) ~[javax.faces-2.3.5.jar:2.3.5]
at org.primefaces.component.api.UIData.getDataModel(UIData.java:792) ~[primefaces-7.0.jar:7.0]
at javax.faces.component.UIData.getRowCount(UIData.java:371) ~[javax.faces-2.3.5.jar:2.3.5]
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:1141) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:1120) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:445) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:376) ~[primefaces-7.0.jar:7.0]
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:95) ~[primefaces-7.0.jar:7.0]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) ~[javax.faces-2.3.5.jar:2.3.5]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223) ~[javax.faces-2.3.5.jar:2.3.5]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671) ~[javax.faces-2.3.5.jar:2.3.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-8.5.31.jar:8.5.31]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
p、 我们只是文字来满足限制只是文字来满足限制只是文字来满足限制只是文字来满足限制只是文字来满足限制只是文字来满足限制只是文字来满足限制
1条答案
按热度按时间axzmvihb1#
spring不可能在对象构造之前在其上注入字段,因此不能在构造函数中使用这些字段。这是为什么现场注入是一个糟糕的选择的众多原因之一。
相反,只需将存储库设置为常规构造函数参数。你甚至不需要
@Autowired
只要只有一个构造函数可供选择。(请注意,从存储库返回的记录通常由一些持久性系统(如jpa)管理,不应该像您现在这样长期存储。相反,重新调用
findAll()
必要时,尽量避免“加载整个世界”(如果可以的话)