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方法
  • 相关阅读:
    01 . Nginx简介及部署
    01 . Ansible原理部署及简单应用
    vue css module
    Expected linebreaks to be 'LF' but found 'CRLF'.
    vue SPA设计 history hash
    vue3 createComponent
    vue3 template refs dom的引用、组件的引用、获取子组件的值
    vue3 父组件给子组件传值 provide & inject
    vue3生命周期
    CSS3 transform变换
  • 原文地址:https://www.cnblogs.com/leeego-123/p/12291310.html
Copyright © 2011-2022 走看看