摘要: 将配置文件里的配置注入到java代码中,这里主要介绍2种属性注入的方式: 方式1:@Component和@ConfigurationProperties注解实现。 方式2:@ConfigurationProperties + @EnableConfigurationProperties注解实现。 1 阅读全文
posted @ 2021-11-17 18:36 shadow321 阅读(221) 评论(0) 推荐(0) 编辑
摘要: ResourceProperties的类,里面就定义了静态资源的默认查找路径: 默认的静态资源路径为: classpath:/META-INF/resources/ classpath:/resources/ classpath:/static/ classpath:/public 如: 访问地址: 阅读全文
posted @ 2021-11-17 18:31 shadow321 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 一、自动配置原理 1. SpringBoot启动的时候加载主配置类,开启了自动配置功能 @EnableAutoConfiguration 2. @EnableAutoConfiguration 作用 利用EnableAutoConfigurationImportSelector给容器中导入一些组件? 阅读全文
posted @ 2021-11-17 18:11 shadow321 阅读(1002) 评论(0) 推荐(0) 编辑
摘要: 这个报错是由于连接数据版本问题,在连接数据库库的url加上: ?serverTimezone=UTC 如下: spring: datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/t 阅读全文
posted @ 2021-11-17 17:47 shadow321 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 1.创建maven项目 2.引入依赖(父工程坐标+web启动器+...) <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3 阅读全文
posted @ 2021-11-17 17:42 shadow321 阅读(53) 评论(0) 推荐(0) 编辑