启动项目时报错(org.springframework.beans.factory.BeanCreationException)

来源:3-5 Hello Spring MVC

慕瓜1027282

2018-11-11 10:24

老师,能帮我看下这个是什么问题么?项目名,配置什么的都是按照您的一样来配置的

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0' defined in ServletContext resource [/WEB-INF/configs/spring/mvc-dispatcher-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'viewClass' of bean class [org.springframework.web.servlet.view.ContentNegotiatingViewResolver]: Bean property 'viewClass' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1506)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)

at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)

at javax.servlet.GenericServlet.init(GenericServlet.java:160)

at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'viewClass' of bean class [org.springframework.web.servlet.view.ContentNegotiatingViewResolver]: Bean property 'viewClass' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


https://img4.mukewang.com/5be792c30001cdfa13650746.jpg

https://img1.mukewang.com/5be792c30001767313660746.jpg

https://img2.mukewang.com/5be792c40001109b13660746.jpg

https://img3.mukewang.com/5be792c60001db6a13660746.jpg


写回答 关注

1回答

  • 慕先生4174394
    2018-12-09 22:00:01

    这个问题是明显viewClass   bean找不到  Does the parameter type of the setter match the return type of the getter?(setter的参数类型是否与getter的返回类型匹配?) 去看下你的get后者set方法是不是写错了,注入不了bean

Spring MVC起步

Java中Spring MVC框架入门教程,快来看最易用的MVC框架

195980 学习 · 572 问题

查看课程

相似问题