【问题标题】:@Lookup method does not work with spring mvc 4.1@Lookup 方法不适用于 spring mvc 4.1
【发布时间】:2019-09-30 10:49:36
【问题描述】:

我想在我正在使用的项目中使用@Lookup 方法的注释。 @Component 声明如下:

@Component
@Scope("prototype")
public class TracciatoCoperturaMondialpolManager {
//some code
}

我的方法在@Service 类中声明如下:

@Lookup
private TracciatoCoperturaMondialpolManager getTracciatoMondialpolManagerPrototype() {
    return null;
}

但是当我从写入的服务类中调用该方法时,它返回 null。我什至尝试使用 xml 如下:

<bean id="tracciatoCoperturaMondialpolManager" class="it.sabacom.amministrativo.tracciati.copertura.TracciatoCoperturaMondialpolManager" scope="prototype" />

<bean id="decodificaService ----
...some xml definitions
        <lookup-method name="getTracciatoMondialpolManagerPrototype" bean="tracciatoCoperturaMondialpolManager"/>
</bean>

但是还是不行,方法继续返回null。出了什么问题?我正在使用 spring mvc 4.1 顺便说一句。感谢您的回答。

【问题讨论】:

    标签: java spring


    【解决方案1】:

    查找方法的修饰符必须受保护或限制较少

    &lt;public|protected&gt; [abstract] &lt;return-type&gt; theMethodName(no-arguments);

    您是否尝试使用此方法签名?

    来自official doc

    【讨论】:

      猜你喜欢
      • 2015-01-11
      • 1970-01-01
      • 2018-04-19
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      • 2018-05-30
      • 2015-05-28
      • 1970-01-01
      相关资源
      最近更新 更多