apache mina自定义编辑器配置器在春季4引发异常

时间:2014-10-22 05:47:53

标签: java spring-4 apache-mina

我在Apache Mina上使用Spring 3,现在我正在使用Spring 4并尝试集成Apache Mina。当我编译时,我在CustomEditorConfigurer中得到一个例外。这是我的豆子:

<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
        <property name="customEditors">
            <map>
                <entry key="java.net.SocketAddress">
                    <bean class="org.apache.mina.integration.beans.InetSocketAddressEditor" />
                </entry>
            </map>
        </property>
    </bean>

如上所述,它会引发以下错误:

Cannot convert value of type [org.apache.mina.integration.beans.InetSocketAddressEditor] to required type [java.lang.Class] for property 'customEditors[java.net.SocketAddress]': PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor] returned inappropriate value of type [org.apache.mina.integration.beans.InetSocketAddressEditor]

Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [org.apache.mina.integration.beans.InetSocketAddressEditor] to required type [java.lang.Class] for property 'customEditors[java.net.SocketAddress]': PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor] returned inappropriate value of type [org.apache.mina.integration.beans.InetSocketAddressEditor]
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:263)
    at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:623)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:208)
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)

问题是否与较新版本的Spring有关?

My Maven依赖项如下:

<properties>
    <org.springframework-version>4.0.6.RELEASE</org.springframework-version>
</properties>

<dependency>
        <groupId>org.apache.mina</groupId>
        <artifactId>mina-core</artifactId>
        <version>2.0.4</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-messaging</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
        <version>${org.springframework-version}</version>
</dependency>

<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.3.2</version>
</dependency>

<dependency>
        <groupId>org.projectreactor</groupId>
        <artifactId>reactor-net</artifactId>
        <version>1.1.0.RELEASE</version>
</dependency>

1 个答案:

答案 0 :(得分:2)

基于此link,它取决于Spring的版本。更改可能因Spring的不同版本而异。

解决了修改列表的问题。

从:

<Entry Key = "java.net.SocketAddress" >  
      <Bean  class = "org.apache.mina.integration.beans.InetSocketAddressEditor"  />  
 </ Entry>  

为:

<Entry Key = "java.net.SocketAddress" value = "org.apache.mina.integration.beans.InetSocketAddressEditor" />