<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"> <property name="port" value="3333"/> </bean> <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean"> <property name="objectName" value="connector:name=rmi" /> <property name="serviceUrl" value="service:jmx:rmi://localhost:50660/jndi/rmi://localhost:3333/jmxrmi" /> <property name="environment"> <!-- the following is only valid when the sun jmx implementation is used --> <map> <entry key="jmx.remote.x.password.file" value="${user.home}/conf/jmxremote.password" /> <entry key="jmx.remote.x.access.file" value="${user.home}/conf/jmxremote.access" /> </map> </property> </bean> <context:mbean-export />
遇到的几个问题:
1、<context:mbean-export />这个配置必须放在最下面
2、如果没有用过RMI暴露远程RPC服务,需要在此处配置注册RMI的Bean
3、如果hostname -i 返回127.0.0.1,外部将无法访问。需要修改/etc/hosts文件,将localhost对应的IP改为分配给你的IP