我有一個要求,允許在我的web應用程序中進行併發會話控制並使可配置字段「max-sessions」。我的配置是這樣的:Spring Security併發會話:未能使「max-sessions」字段可配置
<security:session-management>
<security:concurrency-control max-sessions="${maxConcurrentSessionsCount}" session-registry-ref="sessionRegistry" expired-url="/handleInvalidatedSession.gs4tr"/>
</security:session-management>`
正如您可以猜到,在「services.properties」文件應該有「maxConcurrentSessionsCount」字段,用戶將通過自己的意志設定。 但我在Intelij獲得下一個警告:
"attribute 'max-sessions' on element 'security:concurrency-control' is not valid with respect to its type, 'positiveInteger'".
我成功地「記住我」配置許多其他的東西,如「令牌有效性秒」和「記住,我cookie的」,等等。 任何想法如何解決問題?搜索幾天的互聯網尋求幫助,但失敗。
編輯: 在 「services.properties」 配置: 「maxConcurrentSessionsCount = 2」
在啓動應用程序時,它引發下一個錯誤:
No, it doesn't. It throws next ERROR on starting app:
017-09-14 15點46分:47,724 ERROR [org.gs4tr.projectdirector.service.context.ContextLoaderListener] [localhost-startStop-1] [user:] - org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:來自類路徑資源的XML文檔中的第75行[組織/ gs4tr /基礎/模塊/ webmvc /彈簧/的applicationContext安全默認.xml]無效;嵌套異常是org.xml.sax.SAXParseException; lineNumber:75; columnNumber:72; cvc-datatype-valid.1.2.1:'$ {maxConcurrentSessionsCount}'不是'integer'的有效值。 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399) 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) 在org.springframework。 beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) 在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) 在org.springframework.beans.factory.support。 AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) at org.spri ngframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support。 AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) 在org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContex噸(ContextLoader.java:306) 在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 在org.gs4tr.projectdirector.service.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:73) 在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811) 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251) 的組織。apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
所以你得到一個警告,但它的工作原理?您是否在某處定義了'maxConcurrentSesionsCount'參數? IntelliJ IDEA是否意識到它? – Kayaman
@Kayaman請參閱編輯問題。 – Alex