當(dāng)創(chuàng)建完成項目之后,我們怎么能夠知道在配置文件中,寫入哪些配置。
例如我們創(chuàng)建springboot項目,項目中引入redis。我們的pom文件
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
接下來我們來看我們怎么知道需要配置redis的哪些內(nèi)容
我們搜索到 springboot 的autoconfigure包

圖1
進(jìn)入spring.factories文件,我們來搜索到redis相關(guān)的內(nèi)容,進(jìn)入紅框類里面

圖2
找到Properties注解,后面則為配置項對應(yīng)的參數(shù)類

圖3
進(jìn)入對應(yīng)的RedisProperties文件,我們即可發(fā)現(xiàn)我們需要配置的內(nèi)容

圖4