gpt4 book ai didi

java - 运行我的应用程序时出现错误 "context initialization failed"

转载 作者:行者123 更新时间:2023-12-01 10:40:26 26 4
gpt4 key购买 nike

运行我的 Spring Security 应用程序时出现错误。

这是错误堆栈

   Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name   '(inner bean)#18': Cannot create inner bean '(inner bean)' of type   [org.springframework.security.web.access.AccessDeniedHandlerImpl] while setting bean property   'accessDeniedHandler'; nested exception is org.springframework.beans.factory.BeanCreationException:   Error creating bean with name '(inner bean)#20': Error setting property values; nested exception is   org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'errorPage' threw exception; nested exception is java.lang.IllegalArgumentException: errorPage must begin with '/'at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean (BeanDefinitionValueResolver.java:279)at springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary (BeanDefinitionValueResolver.java:126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues (AbstractAutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean (AbstractAutowireCapableBeanFactory.java:1158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean (BeanDefinitionValueResolver.java:269)
... 40 more





Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot create inner bean '(inner bean)' of type [org.springframework.security.web.access.ExceptionTranslationFilter] while setting constructor argument with key [9]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean) #18': Cannot create inner bean '(inner bean)' of type [org.springframework.security.web.access.AccessDeniedHandlerImpl] while setting bean property 'accessDeniedHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#20': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'errorPage' threw exception; nested exception is java.lang.IllegalArgumentException: errorPage must begin with '/'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean (BeanDefinitionValueResolver.java:279)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary (BeanDefinitionValueResolver.java:126)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList (BeanDefinitionValueResolver.java:350)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary (BeanDefinitionValueResolver.java:154)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments (ConstructorResolver.java:623)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor (ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor (AbstractAutowireCapableBeanFactory.java:1075)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:979)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject (AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference (BeanDefinitionValueResolver.java:320)
... 26 more

最佳答案

在堆栈跟踪中,errorPage 必须以“/”开头

您需要修改 *-security.xml 文件中的条目:

<security:access-denied-handler error-page="/<Your error page controller name>" />

示例:

<security:access-denied-handler error-page="/MyPage.htm" />

错误页面必须始终以“/”开头

关于java - 运行我的应用程序时出现错误 "context initialization failed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34450318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com