Spring boot failed to read .yml

1, application.yml

spring:
  profiles:
    active: dev
  datasource:
    url: jdbc:mysql://192.168.2.201:3306/pmsd?useUnicode=true&characterEncoding=utf8&ssl=false
    username: app_pmsd
    password: 635151_Itp
    driver-class-name: com.mysql.jdbc.Driver
    druid:
      initial-size: 1
      minIdle: 5
      maxActive: 20
      timeBetweenEvictionRunsMillis: 60000
      minEvictableIdleTimeMillis: 300000

2, DataSourceProperties.java

@Component
@ConfigurationProperties(prefix = "spring.datasource")
public class DataSourceProperties {
    private String url;
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
}

3, MybatisConfigurer.java

@Configuration
public class MybatisConfigurer {
    @Autowired
    private DataSourceProperties dataSourceProperties;
    @Bean(name = "dataSource")
    public DataSource dataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setUrl(dataSourceProperties.getUrl());
        //druidDataSource.setUsername(dataSourceProperties.getUserName());
        //druidDataSource.setPassword(dataSourceProperties.getPassWord());
        //druidDataSource.setDriverClassName(dataSourceProperties.getDriverClassName());
        return druidDataSource;
    }
   }

4, pom.xml has references

 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
  </dependency>
The

code is like the above. I got null, when I got dataSourceProperties. Excuse me, where did the gods write it wrong? Thank you

Mar.28,2021

add code to DataSourceProperties

 public DataSource config(DruidDataSource dataSource){
        dataSource.setUrl(url);
        return dataSource;
 }
Change it to

in

MybatisConfigurer

    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        druidProperties.config(dataSource);
        return dataSource;
    }

has been resolved. The reason is that I have another method, MapperScannerConfigurer, in the MybatisConfigurer class, because spring executes the MapperScannerConfigurer method first, and the sqlsessionFactory, has not been created at the time of execution, so it will cause a null pointer exception

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b388bc-2b66d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b388bc-2b66d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?