optional
adj.
可选择的;选修的。
当project-A 依赖project-B, project-B 依赖project-C时
如果在B的pom.xml中将依赖C的optional指定为true
ProjectC
project-A中如果没有显式的手动引入project-C, 则project-A不会依赖project-C, 即project-A可以自己选择是否依赖project-C
如果不在B中配置依赖C的optional树形为true,则默认值为false, 此时A会自动依赖C。
项目springdataredis的pom.xml,我们引入了spring-data-redis这个dependency.
org.springframework.data spring-data-redis2.7.0
我们看到jedis和lettuce均有optional为true的标示,所以我们需要自己引入选择使用哪个redis的驱动。
4.0.0 org.springframework.data spring-data-redis2.7.0 Spring Data Redis Spring Data module for Redis https://spring.io/projects/spring-data-redis org.springframework.data.build spring-data-parent2.7.0 2.7.0 4.0.21.1 1.9.4 1.4.19 2.11.1 6.1.8.RELEASE 3.8.0 1.01 4.1.72.Final spring.data.redis scm:git:https://github.com/spring-projects/spring-data-redis.git scm:git:git@github.com:spring-projects/spring-data-redis.git https://github.com/spring-projects/spring-data-redis GitHub https://github.com/spring-projects/spring-data-redis/issues org.apache.commons commons-pool2${pool} org.springframework.data spring-data-keyvalue${springdata.keyvalue} org.springframework spring-txorg.springframework spring-oxmorg.springframework spring-aoporg.springframework spring-context-supportredis.clients jedis${jedis} true io.lettuce lettuce-core${lettuce} true io.netty netty-transport-native-epolllinux-x86_64 ${netty} test io.netty netty-transport-native-kqueueosx-x86_64 ${netty} test io.projectreactor reactor-coretrue com.fasterxml.jackson.core jackson-coretrue com.fasterxml.jackson.datatype jackson-datatype-jsr310true com.fasterxml.jackson.core jackson-databindtrue commons-beanutils commons-beanutils${beanutils} true org.apache.commons commons-pool2true org.apache.geronimo.specs geronimo-jcdi_2.0_spec1.0.1 test javax.interceptor javax.interceptor-api1.2.1 test javax.enterprise cdi-api${cdi} provided true javax.annotation javax.annotation-api${javax-annotation-api} test org.apache.openwebbeans openwebbeans-se${webbeans} test org.jetbrains.kotlin kotlin-stdlibtrue org.jetbrains.kotlin kotlin-reflecttrue org.jetbrains.kotlinx kotlinx-coroutines-core${kotlin-coroutines} true org.jetbrains.kotlinx kotlinx-coroutines-reactor${kotlin-coroutines} true io.mockk mockk${mockk} test org.springframework spring-jdbctest org.awaitility awaitility${awaitility} test javax.transaction jta${jta} test javax.annotation jsr250-api1.0 test com.thoughtworks.xstream xstream${xstream} test edu.umd.cs.mtc multithreadedtc${multithreadedtc} test io.projectreactor reactor-testtest org.apache.maven.plugins maven-surefire-plugin-XX:-OmitStackTraceInFastThrow false ***Test.java org.apache.maven.plugins maven-assembly-pluginorg.asciidoctor asciidoctor-maven-plugin${lettuce} ${jedis} spring-libs-release https://repo.spring.io/libs-release spring-plugins-release https://repo.spring.io/plugins-release none



