springboot 项目启动类注入HessianProxyFactoryBean

springboot项目中调用hession接口
1.增加pom依赖

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

2.springboot启动类代码

@SpringBootApplication
public class TwpWeixinPublicApplication {

    @Value("${weixinapi.templateMsg}")
    private String templateMsg;

    public static void main(String[] args) {
        SpringApplication.run(TwpWeixinPublicApplication.class, args);
    }

    @Bean
    public HessianProxyFactoryBean helloClient() {
        HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
        factory.setServiceUrl(templateMsg);
        factory.setServiceInterface(TemplateMsgAPIService.class);
        factory.setOverloadEnabled(false);
        return factory;
    }

}

你可能感兴趣的:(Java)