Java 名称为'的bean定义无效;离线代币服务&x27;在ServletContext资源[/WEB-INF/spring security.xml]中定义
感谢您在本地运行Java 名称为'的bean定义无效;离线代币服务&x27;在ServletContext资源[/WEB-INF/spring security.xml]中定义,java,s4sdk,Java,S4sdk,感谢您在本地运行approuter包 现在在本地运行时出现以下异常 我添加了xs.appnamexs.uaa.clientidxs.uaa.identityzonexs.uaa.verificationkey,但只得到了相同的问题 请建议我必须使用环境变量VCAP\u SERVICES [localhost-startStop-1] ERROR com.sap.xs2.security.commons.SAPVcapServicesParser - Environment variable VC
approuter
包
现在在本地运行时出现以下异常
我添加了xs.appname
xs.uaa.clientid
xs.uaa.identityzone
xs.uaa.verificationkey
,但只得到了相同的问题
请建议我必须使用环境变量VCAP\u SERVICES
[localhost-startStop-1] ERROR com.sap.xs2.security.commons.SAPVcapServicesParser - Environment variable VCAP_SERVICES not set
[localhost-startStop-1] WARN org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'offlineTokenServices' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Environment variable VCAP_SERVICES not set; nested exception is java.lang.IllegalStateException: Environment variable VCAP_SERVICES not set
[localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'offlineTokenServices' defined in ServletContext resource [/WEB-INF/spring-security.xml]: Environment variable VCAP_SERVICES not set; nested exception is java.lang.IllegalStateException: Environment variable VCAP_SERVICES not set
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:228)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:225)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:86)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:166)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Environment variable VCAP_SERVICES not set
at com.sap.xs2.security.commons.SAPVcapServicesParser.getAttribute(SAPVcapServicesParser.java:34)
at com.sap.xs2.security.commons.SAPPropertyPlaceholderConfigurer.parseVcapServices(SAPPropertyPlaceholderConfigurer.java:44)
at com.sap.xs2.security.commons.SAPPropertyPlaceholderConfigurer.readVcapServices(SAPPropertyPlaceholderConfigurer.java:67)
at com.sap.xs2.security.commons.SAPPropertyPlaceholderConfigurer.resolvePlaceholder(SAPPropertyPlaceholderConfigurer.java:94)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.resolvePlaceholder(PropertyPlaceholderConfigurer.java:163)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PropertyPlaceholderConfigurerResolver.resolvePlaceholder(PropertyPlaceholderConfigurer.java:264)
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:145)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:244)
at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:296)
at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:217)
at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:147)
at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:85)
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:225)
... 18 common frames omitted
您需要将
VCAP_服务
作为环境变量提供给本地容器,如错误消息所示:java.lang.IllegalStateException:环境变量VCAP_服务未设置
。为此,请向环境变量提供相应的参数,就像将真正的XSUAA实例绑定到CloudFoundry microservice时一样。对于本地部署,您的VCAP\u服务
必须至少具有以下参数,其中verificationkey
属性需要与JWT的签名匹配。此外,标记
属性至关重要
适用于Mac/Unix
如果正确提供了环境变量,则应在本地环境日志输出中看到以下消息:
INFO:get from VCAP_SERVICES:identityzone=uaa
Philipp,我确实在我的环境变量中设置了VCAP_SERVICES
,但没有工作。请告诉我我错过了什么。我的本地环境是windows 10。谢谢Philipp,它与
export VCAP_SERVICES='{
"xsuaa":[
{
"credentials": {
"clientid":"testClient",
"clientsecret":"dummy-clientsecret",
"identityzone":"uaa",
"url":"dummy-url",
"verificationkey":"-----BEGIN PUBLIC KEY-----MIIBI...QIDAQAB-----END PUBLIC KEY-----"
},
"tags":["xsuaa"]
}]
}'