首先解决一下idea新建 yml或是xml没有提示问题

spring boot 加载xml配置文件及注入值

看图标就可以知道 ,两个文件不是一样的,需要下面设置

ctrl+shift+alt+s

spring boot 加载xml配置文件及注入值

初始只有application.yml 没有我后建yml文件

点下面的后框

spring boot 加载xml配置文件及注入值

点击加号,

spring boot 加载xml配置文件及注入值

找到新建 的yml点ok就可以了

 

spring boot 加载xml配置文件及注入值

完美解决

spring boot 加载xml配置文件及注入值

 

在启动类上面加上注解

@importresource

spring boot 加载xml配置文件及注入值

 

相关文章: