gpt4 book ai didi

java - 从 Spring 2 迁移到 Spring 4 时需要属性 'service'

转载 作者:太空宇宙 更新时间:2023-11-04 13:56:00 25 4
gpt4 key购买 nike

此服务器上下文曾经在 Spring 2 中正常工作:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="myService" class = "com.example.service.MyServiceFactory" factory-method="getInstance"/>

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="MyService"/>
<property name="service" ref="myService"/>
<property name="serviceInterface" value="com.example.service.MyService"/>
<property name="registryPort" value="1199"/>
</bean>

</beans>

但是,当我切换到 spring 4.1.6-RELEASE 时,我收到此错误:

java.lang.IllegalArgumentException: Property 'service' is required
at org.springframework.remoting.support.RemoteExporter.checkService(RemoteExporter.java:114)
at org.springframework.remoting.rmi.RmiServiceExporter.prepare(RmiServiceExporter.java:239)
at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet(RmiServiceExporter.java:230)

如何修复它?

最佳答案

升级到 Spring 4 后,MyServiceFactory.getInstance() 中的一行失败并返回 null,因此出现错误。所以服务器上下文没有问题,但这个错误与 Spring 4 并非完全无关。

我希望他们能让错误更加明显,比如错误:属性“service”接收空对象比当前错误消息提供更多信息。

关于java - 从 Spring 2 迁移到 Spring 4 时需要属性 'service',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29812322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com