zoukankan      html  css  js  c++  java
  • httpInvoke的springboot项目打包成jar包作为工具包

    日前接收一个项目,需求是做httpInvoke的工具jar包,为第三方的(非spring和springboot)项目调用:

    配置类:

    @Configuration
    public class ClientConfiguration {
        @Bean
        public HttpInvokerProxyFactoryBean testService() {
            HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
            httpInvokerProxyFactoryBean.setServiceUrl("http://localhost:8080/xxxx/remoting");
            httpInvokerProxyFactoryBean.setServiceInterface(IPassengerService.class);
            return httpInvokerProxyFactoryBean;
        }

    将springboot项目打包成jar包,作为工具包导入项目后,找不到jar中的类。

    原因是:springboot项目使用了自动的打包插件。

    原先的插件配置:

    <build>
        <plugins>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
        </plugins>
      </build>

    改为apache的插件:

     

     <build>
        <plugins>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugins>
      </build>

    第三方的调用:

    首先引入jar包:

     调用实例:

    ApplicationContext applicationContext=new AnnotationConfigApplicationContext(ClientConfiguration.class);    
                IPassengerService serivce = applicationContext.getBean(IPassengerService.class);
                   serivce.findUserName(aa, "cc");   //findUserName 为IPassengerService方法
  • 相关阅读:
    透明代理和匿名代理的区别
    WinForm webbrowser控件的使用
    c# WebBrowser开发参考资料--杂七杂八
    C# Winform WebBrowser控件
    使用webBrowser进行C#和JS通讯
    webBrowser 应用编程函数总结
    C#网页采集数据的几种方式(WebClient、WebBrowser和HttpWebRequest/HttpWebResponse)
    利用WebBrowser控件实现百度自动搜索
    c#winform使用WebBrowser 大全
    ros在QT下编程
  • 原文地址:https://www.cnblogs.com/leeego-123/p/12291310.html
Copyright © 2011-2022 走看看