【问题标题】:How the spring-boot-starter-data-redis works?spring-boot-starter-data-redis 是如何工作的?
【发布时间】:2021-06-20 15:51:29
【问题描述】:

我发现jar只有三个通用文件,没有java文件,没有pom.xml文件。这个怎么运作?迷茫了,谢谢~

➜  jar -tf spring-boot-starter-data-redis-2.5.1.jar
META-INF/
META-INF/MANIFEST.MF
META-INF/LICENSE.txt
META-INF/NOTICE.txt

【问题讨论】:

    标签: spring-data-redis


    【解决方案1】:

    该包还包括一个 pom.xml,它定义了对其他项目的一些依赖项,例如 spring-data-redis、lettuce-core。这些依赖项将包含在您的构建过程中。 所以jar中没有实际的代码。

    来自 spring-boot-starter-data-redis 2.0.6-RELEASE pom.xml 的示例:

     <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter</artifactId>
          <version>2.0.6.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-redis</artifactId>
          <version>2.0.11.RELEASE</version>
          <scope>compile</scope>
          <exclusions>
            <exclusion>
              <artifactId>jcl-over-slf4j</artifactId>
              <groupId>org.slf4j</groupId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
          <groupId>io.lettuce</groupId>
          <artifactId>lettuce-core</artifactId>
          <version>5.0.5.RELEASE</version>
          <scope>compile</scope>
        </dependency>
      </dependencies>

    【讨论】:

      【解决方案2】:

      正如 Luc 所说,如果您查看工件内部,您会看到一个 POM https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-data-redis/2.5.2/spring-boot-starter-data-redis-2.5.2.pom,它带来了所有需要的依赖项。 Baeldung 有一篇关于初学者如何工作的好文章https://www.baeldung.com/spring-boot-starters

      【讨论】:

        【解决方案3】:

        代码在jar spring-boot-autoconfigure,在包org.springframework.boot.autoconfigure.data.redis,核心类是RedisAutoConfiguration

        【讨论】:

          猜你喜欢
          • 2022-12-28
          • 1970-01-01
          • 1970-01-01
          • 2021-11-11
          • 2021-01-18
          • 2021-02-09
          • 2017-03-23
          • 2022-11-10
          • 2014-12-29
          相关资源
          最近更新 更多