2022-4-24

springboot学习第一天:

  • 自定义banner
  • 配置文件,自定义属性注入@ConfigurationProperties @Value
  • 自定义注解

学习内容:

自定义banner

在classpath下新建banner.txt

  1. 配置文件使用spring.banner.location设置
  2. 配置文件使用spring.banner.image.location设置

支持txt、png、jpg、gif格式

配置文件,属性自动注入

@ConfigurationProperties
prefix属性配置前缀
需要配合@Component注解搭配使用(目的在于将当前类注入到spring容器中)

@Value(“${user.name}”)使用方式
不用提供set方法

配置文件优先级
classpath:./config/>classpath:./

环境区分
application-dev.yaml
application-test.yaml

使用spring.profiles.active=dev进行设置

自定义注解

新建:public @interface MyAnnotation

jdk自带4个元注解:
1、@Target(ElementType.FIELD):注解使用目标位置(字段)
2、@Retention(RetentionPolicy.RUNTIME):注解生命周期,什么时候生效(运行时期)
3、@Inherited:表明改注解支持继承特性
4、@Documented:支持文档注释

注解中的属性
String name() default ‘hehe’

Class[] mc() defalult {}

boolean proxyBeanMethods() default true;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱马氏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值