English 中文(简体)
iii
原标题:@Scope ( INTERFACES ) equivalent for XML

Im试图在旧学校Xml这样做(密码)。

@Bean
    @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)   
    public MyInterface createInterface() {
        return connectionRepository().getPrimaryConnection(MyInterface.class);
    }

我试图这样做:

    <bean id="myBean" class="a.b.c.MyInterface"
        factory-bean="myFactory" factory-method="create"
        scope="request">
        <constructor-arg value="a.b.c.MyInterface"></constructor-arg>
        <aop:scoped-proxy proxy-target-class="false"/>
    </bean>

但一味:

Cannot换算类型的价值[$Proxy12 implementing java.io.Serializable,org. Cerframework.aop.framework.AopInfrastructureBean,org. mersframework.aop. SpringProxy,org.merframework.aop.framework.Advised] to required category [a.b.c.MyInterface] for property myBean : no对编编辑或转化战略没有发现。

Any ideas? Thanks!

最佳回答

这里是最终如何运作。 skaffman正在挖掘:

<bean id="factory"
    class="a.b.c.Factory"
    scope="request">
</bean>

<bean id="facebook" class="a.b.c.MyInterface"
    factory-bean="factory" factory-method="createObject"
    scope="request">
    <aop:scoped-proxy proxy-target-class="false"/>
</bean>
问题回答

这为我工作:

界定贵方:

package com.bit.impl;

public class MyBeanImpl implements MyBean{
     ....
     ....
}

在您的附录中加入这一法典。

<bean id="bean" class="com.bit.impl.MyBeanImpl" scope="session" >
     <aop:scoped-proxy />
</bean>

现在,如果你想测试你的话,你需要增加下一个组合:

<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
    <property name="scopes">
        <map>
            <entry key="session">
                <bean class="org.springframework.context.support.SimpleThreadScope"/>
            </entry>
        </map>
    </property>
</bean>

而这一切!

我希望这有益!

regards!

首先,你的XML实例似乎与 Java版本相当——在 where版本中,有人要求<条码>连接(>)。 Alaos, 错误信息是指财产myBean, 而您则按该名称而不是财产对地标。 我很想知道,你的错误信息是否确实来自XML碎片,还是来自不同的碎片。

除此以外,你的问题可能与以下事实有关:你重新指定了<条码><>>> > >、<条码>--bean和<条码> 。 与此同时。 通常只有其中两个,而不是所有三个。

Try omitting class, just leaving factory-bean="myFactory" factory-method="create". Spring will infer the type of your bean from the return type of the factory method.





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签