1. 程式人生 > >spring 整合 hessian要注意的兩點問題

spring 整合 hessian要注意的兩點問題

首先除了spring的依賴,還需要加上 hessian的依賴

 <dependency>
			<groupId>com.caucho</groupId>
			<artifactId>hessian</artifactId>
			<version>4.0.51</version>
		</dependency>

其次是要注意註冊對映的時候,對映的bean的id並不是實現類的id,而是HessianServiceExporter型別的bean的id。比如,我的實現類的名稱是spittleServiceImpl,HessianServiceExporter 的名稱是hessianServiceExporter(預設是方法名),這裡應該寫的是hessianServiceExporter

@Bean
	public HessianServiceExporter hessianServiceExporter(SpittleService service) {

		HessianServiceExporter exporter=new HessianServiceExporter();
		exporter.setService(service);
		exporter.setServiceInterface(SpittleService.class);
		return exporter;
	}
	@Bean(name="spittleServiceImpl")
	public SpittleService spittleServiceImpl() {
		return new SpittleServiceImpl();
	}
	@Bean
	public HandlerMapping hessianMapping() {
		SimpleUrlHandlerMapping mapping=new SimpleUrlHandlerMapping();
		Properties properties=new Properties();
		//hessianExportSpitterService是HessionServiceExporter型別的bean的id
		properties.setProperty("/spittle.service","**hessianServiceExporter**");
		mapping.setMappings(properties);
		return mapping;
	}