Springboot not loading application.dev.properties file

北战南征 提交于 2019-12-04 02:08:18
Kyle Anderson

A few issues I noticed:

  1. @Value property name should be a String like @Value("${server.database.host}")
  2. Profile specific property files should follow application-{profile}.properties format, e.g. application-dev.properties
  3. Try passing the profile with -D like java -Dspring.profiles.active=dev -jar app.jar

Try adding a vm argument in the run configuration:

-Dspring.profiles.active=dev

If running on Eclipse or STS, then use following steps:

  1. Right click on project -> Run As -> Run Configuration.

  2. In the new window, select spring boot application on left side, and add details on the right and in the profile dropdown, select dev.

  3. Click apply and run.

hreinn

You are supposed to specify which profile to run with as follows:

mvn spring-boot:run -Dspring-boot.run.profiles=foo,bar

Also see documentation: https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-profiles.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!