有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在Spring boot中添加会话bean导致没有为作用域“Session”注册作用域

我有一个问题,无法在spring boot中添加会话bean。在我的申请中。xml我已经定义了2个bean,其作用域为session,我在“leadsJobSchedule”控制器中引用了它,如下所示

应用程序。xml

  <bean id="leadsJobSchedule" class="za.co.discovery.portal.vitality.util.LeadsJobSchedule">
     <property name="leadDetailsMap" ref="leadDetailsMap"/>
     <property name="googleAnalyticsHelper" ref="googleAnalyticsHelper"/>
  </bean>

  <bean id="googleAnalyticsHelper" class="za.co.discovery.portal.vitality.util.GoogleAnalyticsHelper" scope="session">
     <property name="readTimeout" value="${timeout.read}" />
     <property name="connectionTimeout" value="${timeout.connect}" />
     <property name="gaTrackingId" value="UA-63460442-1"/>
     <property name="proxyAuthenticator" ref="proxyAuthenticator" />
  </bean>

  <bean id="proxyAuthenticator" class="za.co.discovery.portal.vitality.util.ProxyAuthenticator" scope="session">
    <property name="proxyHost" value="${proxy.host}" />
    <property name="proxyPort" value="${proxy.port}" />
    <property name="username" value="${proxy.username}" />
    <property name="password" value="${proxy.password}" />
  </bean>

在spring boot中启动apache时,出现以下错误:

Could not autowire field: private za.co.discovery.portal.vitality.util.GoogleAnalyticsHelper za.co.discovery.portal.vitality.util.LeadsJobSchedule.googleAnalyticsHelper; nested exception is java.lang.IllegalStateException: No Scope registered for scope 'session'
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:124)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142)
    at za.co.discovery.portal.vitality.Application.main(Application.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource .

共 (0) 个答案