why application.yml doesn't work in my springboot

27 Views Asked by At

I am new to the springboot. I want to change the default port 8080 to 9001.

Under the below image, I added a applicaton.yml,

server:
  port: 9001

but it dosen't work. While I added in application.properties it works.

My problem is my applicaton.yml seems no any relation with my project, I don't know why. enter image description here

applicaton.yml should be working the way application.properties

1

There are 1 best solutions below

0
Jiao On

I added :

System.setProperty("spring.config.name", "application");

in the TestApplication class, SpringBoot load application.yml file!

@SpringBootApplication
public class TestApplication {

    public static void main(String[] args) {
        System.setProperty("spring.config.name", "application");
        SpringApplication.run(TestApplication.class, args);
    }

}