Okhttp再分析<二>

再分析第二篇准备讲讲CallServerInterceptor。先OkHttp的RealConnection 说起,它主要是创建链接,创建链接分为两部分。分为createTunnel(这不是直接连接服务器,是链接的代理服务器)和connectSocket 通过socket直接连接,(socket 是实现http协议的api),主要分析createSocket吧。

 /** Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket. */
  private void connectSocket(int connectTimeout, int readTimeout, Call call,
      EventListener eventListener) throws IOException {
    //proxy 的type分为直接连接,socket代理,http代理(一般Https,Ftp这种协议直接)  
    Proxy proxy = route.proxy();
    //获取地址。Address 属于服务器的抽象定义,如果直连,这注意hostname和port。如果是代理还包含代理信息,SocketFactory,证书等。
    Address address = route.address();
    //如果是直连或者http代理,那么直接获取到socket,否则传进去new Socket,socketFactory() 获取的是
    //DefaultSocketFactory 工厂。
    rawSocket = proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.HTTP
        ? address.socketFactory().createSocket()
        : new Socket(proxy);

    eventListener.connectStart(call, route.socketAddress(), proxy);
    rawSocket.setSoTimeout(readTimeout);
    try {
    // 正式连接到socket。
      Platform.get().connectSocket(rawSocket, route.socketAddress(), connectTimeout);
    } catch (ConnectException e) {
      ConnectException ce = new ConnectException("Failed to connect to " + route.socketAddress());
      ce.initCause(e);
      throw ce;
    }

    // The following try/catch block is a pseudo hacky way to get around a crash on Android 7.0
    // More details:
    // https://github.com/square/okhttp/issues/3245
    // https://android-review.googlesource.com/#/c/271775/
    try {
    // Okio 粉墨登出,一句话它是链接socket,然后从中读取byte,转换为buffer。source输入输入流,sink是读取流,source 我们用于写入header和requestBody信息。sink我们用于读取RequestBody的信息。
      source = Okio.buffer(Okio.source(rawSocket));
      sink = Okio.buffer(Okio.sink(rawSocket));
    } catch (NullPointerException npe) {
      if (NPE_THROW_WITH_NULL.equals(npe.getMessage())) {
        throw new IOException(npe);
      }
    }
  }

这里我们看到了非常重要的角色souce和sink。现在回到CallServerInterceptor.记住source 是读入流,sink属于写入流。

  @Override public Response intercept(Chain chain) throws IOException {
    RealInterceptorChain realChain = (RealInterceptorChain) chain;
    HttpCodec httpCodec = realChain.httpStream();
    StreamAllocation streamAllocation = realChain.streamAllocation();
    RealConnection connection = (RealConnection) realChain.connection();
    Request request = realChain.request();
    //注意前面的赋值在ConnectInterceptor 里面,HttpCodec 现在是HttpCodec1。
    //到这里代表socket已经正式建立了连接。现在只需要通过Http协议与Server进行交互了。
    long sentRequestMillis = System.currentTimeMillis();
    
    realChain.eventListener().requestHeadersStart(realChain.call());
    // public void writeRequest(Headers headers, String requestLine) throws IOException {
    //if (state != STATE_IDLE) throw new IllegalStateException("state: " + state);
    //sink.writeUtf8(requestLine).writeUtf8("\r\n");
    //for (int i = 0, size = headers.size(); i < size; i++) {
    //  sink.writeUtf8(headers.name(i))
    //      .writeUtf8(": ")
    //      .writeUtf8(headers.value(i))
    //      .writeUtf8("\r\n");
   // }
   // sink.writeUtf8("\r\n");
   // state = STATE_OPEN_REQUEST_BODY;
 // }
 // 通过我之前分析的拿到sink以后就可以写入RequestHeader 逻辑essay。
    httpCodec.writeRequestHeaders(request);
    realChain.eventListener().requestHeadersEnd(realChain.call(), request);

    Response.Builder responseBuilder = null;
    if (HttpMethod.permitsRequestBody(request.method()) && request.body() != null) {
      // If there's a "Expect: 100-continue" header on the request, wait for a "HTTP/1.1 100
      // Continue" response before transmitting the request body. If we don't get that, return
      // what we did get (such as a 4xx response) without ever transmitting the request body.
      if ("100-continue".equalsIgnoreCase(request.header("Expect"))) {
        httpCodec.flushRequest();
        realChain.eventListener().responseHeadersStart(realChain.call());
        responseBuilder = httpCodec.readResponseHeaders(true);
      }
       // 100-continue 就是询问服务器是否处理Post数据,如果处理走下面的逻辑。 
      if (responseBuilder == null) {
        //
        // Write the request body if the "Expect: 100-continue" expectation was met.
        realChain.eventListener().requestBodyStart(realChain.call());
        long contentLength = request.body().contentLength();
        CountingSink requestBodyOut =
            new CountingSink(httpCodec.createRequestBody(request, contentLength));
        BufferedSink bufferedRequestBody = Okio.buffer(requestBodyOut);
        // 对于POST,body为FormBody。写入RequetBody内容。
        request.body().writeTo(bufferedRequestBody);
        bufferedRequestBody.close();
        realChain.eventListener()
            .requestBodyEnd(realChain.call(), requestBodyOut.successfulCount);
      } else if (!connection.isMultiplexed()) {
        // If the "Expect: 100-continue" expectation wasn't met, prevent the HTTP/1 connection
        // from being reused. Otherwise we're still obligated to transmit the request body to
        // leave the connection in a consistent state.
        streamAllocation.noNewStreams();
      }
    }
    //HttpCodc1 持有sink和source,完成请求。
    httpCodec.finishRequest();

    if (responseBuilder == null) {
      realChain.eventListener().responseHeadersStart(realChain.call());
      responseBuilder = httpCodec.readResponseHeaders(false);
    }
    //实际这个是读取两次这个Response,这是地此意,读取到这个code=100
    Response response = responseBuilder
        .request(request)
        .handshake(streamAllocation.connection().handshake())
        .sentRequestAtMillis(sentRequestMillis)
        .receivedResponseAtMillis(System.currentTimeMillis())
        .build();

    int code = response.code();
    //code=100 代表读取正常,可以
    if (code == 100) {
      // server sent a 100-continue even though we did not request one.
      // try again to read the actual response
      responseBuilder = httpCodec.readResponseHeaders(false);
    //再读取一次。
      response = responseBuilder
              .request(request)
              .handshake(streamAllocation.connection().handshake())
              .sentRequestAtMillis(sentRequestMillis)
              .receivedResponseAtMillis(System.currentTimeMillis())
              .build();

      code = response.code();
    }

    realChain.eventListener()
            .responseHeadersEnd(realChain.call(), response);

    if (forWebSocket && code == 101) {
      // Connection is upgrading, but we need to ensure interceptors see a non-null response body.
      response = response.newBuilder()
          .body(Util.EMPTY_RESPONSE)
          .build();
    } else {
    //实际读取到ResposeBody。实际上openResonseBody也是通过source,read byte转换为ResponseBody,到这里我们就获取到结果了。返回到response。
      response = response.newBuilder()
          .body(httpCodec.openResponseBody(response))
          .build();
    }

    if ("close".equalsIgnoreCase(response.request().header("Connection"))
        || "close".equalsIgnoreCase(response.header("Connection"))) {
      streamAllocation.noNewStreams();
    }

    if ((code == 204 || code == 205) && response.body().contentLength() > 0) {
      throw new ProtocolException(
          "HTTP " + code + " had non-zero Content-Length: " + response.body().contentLength());
    }

    return response;
  }

这里CallServerInterceptor就分析完了,没有分析太深入,后续有机会再次深入去了解吧,都是一些http请求的细节了。

com.alipay.easysdk.factory.Payment.Page() orderMapper.updatePayStatus(outTradeNo, alipayTradeNo, new Date(), 2);这个报错和xml文件有关吗<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!--父工程依赖 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.5</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.pyk</groupId> <artifactId>1</artifactId> <version>0.0.1-SNAPSHOT</version> <name>cloud_class_gitee</name> <description>cloud_class_gitee</description> <url/> <licenses> <license/> </licenses> <developers> <developer/> </developers> <scm> <connection/> <developerConnection/> <tag/> <url/> </scm> <properties> <java.version>17</java.version> <maven.exam.skip>true</maven.exam.skip> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> </dependency> <!-- 单元测试依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter-test</artifactId> <version>2.2.2</version> <scope>test</scope> </dependency> <!-- lombok依赖--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> <!-- validation依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <!--java-jwt依赖 --> <dependency> <groupId>com.auth0</groupId> <artifactId>java-jwt</artifactId> <version>4.4.0</version> </dependency> <!--pagehelper 工具 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.4.6</version> </dependency> <!-- MinIO Java SDK --> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.3.4</version> </dependency> <!-- swagger Api 接口 --> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>3.0.2</version> </dependency> <!--redis依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!-- excel导入导出--> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>3.0.5</version> </dependency> <dependency> <groupId>org.burningwave</groupId> <artifactId>core</artifactId> <version>9.5.2</version> </dependency> <!--上传文件--> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>3.1.0</version> <!-- 使用最新版本 --> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.76</version> </dependency> <!--集合工具类--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.16</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> </dependency> <!-- 切面编程 登录操作日志--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!--登录验证码--> <dependency> <groupId>com.github.whvcse</groupId> <artifactId>easy-captcha</artifactId> <version>1.6.2</version> </dependency> <!--okhttp3--> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.9.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.9.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>3.4.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.15.2</version> <!-- 确保版本一致 --> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.15.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.15.2</version> </dependency> <!-- 支付宝依赖沙箱支付 --> <dependency> <groupId>com.alipay.sdk</groupId> <artifactId>alipay-easysdk</artifactId> <version>2.2.0</version> </dependency> <!-- 支付宝相关--> <dependency> <groupId>com.alipay.sdk</groupId> <artifactId>alipay-sdk-java</artifactId> <version>4.34.0.ALL</version> </dependency> <dependency> <groupId>com.alipay.sdk</groupId> <artifactId>alipay-easysdk</artifactId> <version>2.2.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
11-06
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.gdsc.bio</groupId> <artifactId>bio-backend-service</artifactId> <version>1.1.39</version> <!-- 定义profile --> <profiles> <!-- 开发环境 --> <profile> <id>dev</id> <properties> <!-- 定义profileActive属性 --> <profileActive>dev</profileActive> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <!-- 测试环境 --> <profile> <id>test</id> <properties> <profileActive>test</profileActive> </properties> </profile> <!-- 生产环境 --> <profile> <id>prod</id> <properties> <profileActive>release</profileActive> </properties> </profile> </profiles> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> <relativePath/> </parent> <dependencies> <!--okhttp--> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.14.9</version> </dependency> <!--test--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.0.7</version> </dependency> <!--rabbitmq消息队列--> <!--rabbitmq--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- Lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <!--集成springmvc框架并实现自动配置 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 排除log4j --> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> <exclusion> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </exclusion> <exclusion> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> </exclusion> </exclusions> </dependency> <!-- 使用最新的logback --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.10</version> </dependency> <dependency> <groupId>com.gdsc</groupId> <artifactId>scadp-core</artifactId> <version>2.48-SNAPSHOT</version> <!--排除自带的poi--> <exclusions> <exclusion> <groupId>org.apache.poi</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.2.5.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/commons-digester/commons-digester --> <dependency> <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> <version>1.6</version> <exclusions> <exclusion> <artifactId>commons-beanutils</artifactId> <groupId>commons-beanutils</groupId> </exclusion> </exclusions> </dependency> <!-- https://mvnrepository.com/artifact/commons-collections/commons-collections --> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.1</version> </dependency> <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils --> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.8.3</version> </dependency> <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all --> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>2.4.12</version> </dependency> <!-- https://mvnrepository.com/artifact/com.lowagie/itext --> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>2.1.7</version> </dependency> <!-- https://mvnrepository.com/artifact/com.lowagie/itextasian --> <dependency> <groupId>com.lowagie</groupId> <artifactId>itextasian</artifactId> <version>1.5.2</version> </dependency> <dependency> <groupId>org.jbarcode</groupId> <artifactId>jbarcode</artifactId> <version>0.2.8</version> </dependency> <dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.0</version> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.30</version> </dependency> <dependency> <groupId>com.qrcode</groupId> <artifactId>qrcode</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext-rtf</artifactId> <version>2.1.7</version> </dependency> <!-- Swagger API文档 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>swagger-bootstrap-ui</artifactId> <version>1.9.3</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-bean-validators</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-jexl</artifactId> <version>2.0</version> </dependency> <!-- nacos --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <version>2.1.0.RELEASE</version> </dependency> <!-- 如果走配置中心需要添加此依赖--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <version>2.1.0.RELEASE</version> </dependency> <!--<!– https://mvnrepository.com/artifact/com.jfinal/jfinal –>--> <!--<dependency>--> <!--<groupId>com.jfinal</groupId>--> <!--<artifactId>jfinal</artifactId>--> <!--<version>3.4</version>--> <!--</dependency>--> <!--<!– https://mvnrepository.com/artifact/log4j/log4j –>--> <!--<dependency>--> <!--<groupId>log4j</groupId>--> <!--<artifactId>log4j</artifactId>--> <!--<version>1.2.17</version>--> <!--</dependency>--> <!--<dependency>--> <!--<groupId>org.slf4j</groupId>--> <!--<artifactId>slf4j-api</artifactId>--> <!--<version>1.7.25</version>--> <!--</dependency>--> <!--<!– https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api –>--> <!--<dependency>--> <!--<groupId>javax.servlet</groupId>--> <!--<artifactId>javax.servlet-api</artifactId>--> <!--<version>3.1.0</version>--> <!--<scope>provided</scope>--> <!--</dependency>--> <!-- scadp-service-api --> <!-- <dependency>--> <!-- <groupId>com.gdsc</groupId>--> <!-- <artifactId>scadp-service-api</artifactId>--> <!-- <version>1.0.2-SNAPSHOT</version>--> <!-- </dependency>--> <!-- xxl-job-core --> <dependency> <groupId>com.xuxueli</groupId> <artifactId>xxl-job-core</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>net.sf.jxls</groupId> <artifactId>jxls-core</artifactId> <version>1.0.1</version> <!--排除自带的poi--> <exclusions> <exclusion> <groupId>org.apache.poi</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-jexl3</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>4.0.3</version> <!--排除自带的poi--> <!-- <exclusions>--> <!-- <exclusion>--> <!-- <groupId>org.apache.poi</groupId>--> <!-- <artifactId>*</artifactId>--> <!-- </exclusion>--> <!-- </exclusions>--> </dependency> <!-- 日志 --> <!-- logback-classic --> <!-- <dependency>--> <!-- <groupId>ch.qos.logback</groupId>--> <!-- <artifactId>logback-classic</artifactId>--> <!-- </dependency>--> <!-- skywalking的logback依赖 --> <dependency> <groupId>org.apache.skywalking</groupId> <artifactId>apm-toolkit-logback-1.x</artifactId> <version>8.7.0</version> </dependency> <!--与logstash对应的日志收集依赖--> <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.10</version> </dependency> </dependencies> <build> <finalName>${project.name}-${project.version}-${profileActive}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <artifactSet> <includes> <include>net.sf.jxls:jxls-core</include> <include>org.apache.poi:poi</include> <include>org.apache.poi:poi-ooxml</include> </includes> </artifactSet> <relocations> <relocation> <pattern>org.apache.poi</pattern> <shadedPattern>shaded.jxls.poi</shadedPattern> </relocation> </relocations> <transformers> <!-- 1. 处理 Manifest 文件 --> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/> <!-- 2. 合并 Service Loader 文件 --> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> <!-- 3. 合并其他资源文件(如 spring.handlers) --> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!--<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> 指定JDK编译版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- 打包跳过测试 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <!-- 避免font文件的进制文件格式压缩破坏 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <nonFilteredFileExtensions> <nonFilteredFileExtension>jasper</nonFilteredFileExtension> <nonFilteredFileExtension>jrxml</nonFilteredFileExtension> <nonFilteredFileExtension>xls</nonFilteredFileExtension> <nonFilteredFileExtension>xlsx</nonFilteredFileExtension> <nonFilteredFileExtension>ftl</nonFilteredFileExtension> <nonFilteredFileExtension>doc</nonFilteredFileExtension> <nonFilteredFileExtension>docx</nonFilteredFileExtension> <nonFilteredFileExtension>woff</nonFilteredFileExtension> <nonFilteredFileExtension>woff2</nonFilteredFileExtension> <nonFilteredFileExtension>eot</nonFilteredFileExtension> <nonFilteredFileExtension>ttf</nonFilteredFileExtension> <nonFilteredFileExtension>svg</nonFilteredFileExtension> </nonFilteredFileExtensions> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xls</include> <include>**/*.xlsx</include> <include>**/*.xml</include> <include>**/*.json</include> <include>**/*.ftl</include> </includes> </resource> <!--<resource> <directory>src/main/resources/template</directory> </resource> <resource> <directory>src/main/resources/watermark</directory> </resource> <resource> <directory>src/main/resources/additional</directory> </resource>--> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <excludes> <exclude>**/*.xls</exclude> <exclude>**/*.xlsx</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>**/*.xml</include> <include>**/*.xls</include> <include>**/*.xlsx</include> <include>**/*.jasper</include> <include>**/*.jrxml</include> </includes> </resource> </resources> </build> </project> Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer
06-18
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.ramaxel</groupId> <artifactId>assets-infrastructure-service</artifactId> <version>1.0.0-RELEASE</version> <name>assets-infrastructure-service</name> <description>infrastructure-service project for Spring Boot</description> <properties> <java.version>1.8</java.version> <skipTests>true</skipTests> <common.base.version>1.0.0-RELEASE</common.base.version> <common.database.version>1.0.0-RELEASE</common.database.version> <common.jwt-login.version>1.0.0-RELEASE</common.jwt-login.version> <common.xxl-job.version>1.0.0-RELEASE</common.xxl-job.version> <common.log-operation.version>1.0.0-RELEASE</common.log-operation.version> <common.log-request.version>1.0.0-RELEASE</common.log-request.version> <common.redis.version>1.0.0-RELEASE</common.redis.version> <java.mail.version>1.4.7</java.mail.version> <spring.cloud.version>2020.0.4</spring.cloud.version> <spring.cloud.alibaba.version>2.2.2.RELEASE</spring.cloud.alibaba.version> <common.jexl.version>2.1.1</common.jexl.version> <axis.version>1.4</axis.version> <jaxrpc.version>1.1</jaxrpc.version> <commons.discovery.version>0.2</commons.discovery.version> <wsdl4j.version>1.5.1</wsdl4j.version> <saaj.api.version>1.3</saaj.api.version> <common.rabbitmq.version>1.0.0-RELEASE</common.rabbitmq.version> <jsch.version>0.1.54</jsch.version> <aviator.version>5.3.3</aviator.version> <okhttp3.version>3.10.0</okhttp3.version> <caffeine.version>2.9.3</caffeine.version> </properties> <dependencies> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.3</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> <version>3.0.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-loadbalancer</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <exclusions> <exclusion> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <!--WebSocket--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-ldap</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>base</artifactId> <version>${common.base.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>database</artifactId> <version>${common.database.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>jwt-login</artifactId> <version>${common.jwt-login.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>rabbitmq</artifactId> <version>${common.rabbitmq.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>xxl-job</artifactId> <version>${common.xxl-job.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>log-operation</artifactId> <version>${common.log-operation.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>log-request</artifactId> <version>${common.log-request.version}</version> </dependency> <dependency> <groupId>com.ramaxel</groupId> <artifactId>redis</artifactId> <version>${common.redis.version}</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>${java.mail.version}</version> </dependency> <!--执行string代码--> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-jexl</artifactId> <version>${common.jexl.version}</version> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>${axis.version}</version> </dependency> <dependency> <groupId>commons-discovery</groupId> <artifactId>commons-discovery</artifactId> <version>${commons.discovery.version}</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>${wsdl4j.version}</version> </dependency> <dependency> <groupId>javax.xml</groupId> <artifactId>jaxrpc</artifactId> <version>${jaxrpc.version}</version> </dependency> <dependency> <groupId>javax.xml.soap</groupId> <artifactId>saaj-api</artifactId> <version>${saaj.api.version}</version> </dependency> <!-- SFTF 文件传输--> <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>${jsch.version}</version> </dependency> <dependency> <groupId>com.googlecode.aviator</groupId> <artifactId>aviator</artifactId> <version>${aviator.version}</version> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>${okhttp3.version}</version> </dependency> <!-- 引入Micrometer与Prometheus集成的依赖库。Micrometer是一个度量收集库,用于在Java应用程序中收集度量标准。 Prometheus是一个开源监控系统,它通过HTTP拉取(pull)的方式收集时间序列数据。 这个依赖允许Spring Boot应用与Prometheus监控系统集成,以便暴露其度量数据给Prometheus。 - groupId: io.micrometer 表示该依赖库所属的组。 - artifactId: micrometer-registry-prometheus 表示具体的依赖库名称。 --> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>${caffeine.version}</version> <!-- 推荐使用稳定版本 --> </dependency> </dependencies> <!--全局引入springcloudalibaba下载依赖地址,并不会引入依赖--> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring.cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring.cloud.alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <!-- <build>--> <!-- <plugins>--> <!-- <plugin>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-boot-maven-plugin</artifactId>--> <!-- <configuration>--> <!-- <layout>ZIP</layout>--> <!-- </configuration>--> <!-- </plugin>--> <!-- </plugins>--> <!-- </build>--> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>dev</id> <properties> <spring.profiles>dev</spring.profiles> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>localhost</id> <properties> <spring.profiles>localhost</spring.profiles> </properties> </profile> <profile> <id>test</id> <properties> <spring.profiles>test</spring.profiles> </properties> </profile> <profile> <id>prod</id> <properties> <spring.profiles>prod</spring.profiles> </properties> </profile> </profiles> <distributionManagement> <repository> <id>releases</id> <name>releases Repository</name> <url>http://10.2.200.94:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>snapshots Repository</name> <url>http://10.2.200.94:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> </project>
11-11
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值