星驰编程网

免费编程资源分享平台_编程教程_代码示例_开发技术文章

springboot快速查看自动配置的类和application.yml配置的属性

1.找到springboot的自动配置包的spring.factories文件。

路径:
org/springframework/boot/spring-boot-autoconfigure/2.1.9.RELEASE/spring-boot-autoconfigure-2.1.9.RELEASE.jar!
/META-INF/spring.factories

2.找数据源的自动配置路径,按住Ctrl+鼠标点击。进入到数据源的自动配置类。如下:

3.进去后可以看到@EnableConfigurationProperties传入的DataSourceProperties类,再点击进去。

4.可以看到平时在application.yml的配置时的提示属性。

5.例如找application.yml中的redis属性配置:

5.1.在
org.springframework.boot.autoconfigure包中找到spring.factories文件。

位置:

/org/springframework/boot/spring-boot-autoconfigure/2.5.0/spring-boot-autoconfigure-2.5.0.jar!
/META-INF/spring.factories。

在文件中找到
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration。


5.2.Ctrl+鼠标点击,进入此类。
找到@
EnableConfigurationProperties({RedisProperties.class})中的RedisProperties类


5.3.Ctrl+鼠标点击,进入此类,aplication.yml中redis配置的属性都在这里。


@ConfigurationProperties(
prefix = "spring.redis"
)
public class RedisProperties {
private int database = 0;
private String url;
private String host = "localhost";
private String username;
private String password;
private int port = 6379;
private boolean ssl;
private Duration timeout;
private Duration connectTimeout;
private String clientName;
private RedisProperties.ClientType clientType;
private RedisProperties.Sentinel sentinel;
private RedisProperties.Cluster cluster;
private final RedisProperties.Jedis jedis = new RedisProperties.Jedis();
private final RedisProperties.Lettuce lettuce = new RedisProperties.Lettuce();
...
}

redis的配置属性都在这里。其他的aplication.yml的配置属性的查找也一样。

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言