0

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

Jiao
  • 111
  • 1
  • 3
  • @SpringBootApplication public class TestApplication { public static void main(String[] args) { System.setProperty("spring.config.name", "application"); SpringApplication.run(TestApplication.class, args); } } – Jiao Nov 09 '22 at 02:09

1 Answers1

0

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);
    }

}
Jiao
  • 111
  • 1
  • 3