For most people the refresh of Gradle that has already been suggested might solve the issue.
For the others I figured out, that deleting the .idea direcotory and reimporting the project might help.
It can be that your resources directory is not added to classpath when creating a project via Spring Initializr. So your application is never loading the application.properties file that you have configured.
To make a quick test if this is the case, add the following to your application.properties file:
server.port=8081
Now when running your application you should see in the spring boot console output something like this:
INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): **8081** (http) with context path ''
If your port is still default 8080 and not changed to 8081, your application.properties files is obviously not loading.
You can also check if your application runs with gradle bootRun
from command line. Which most likely will be work.
Solution:
- Close IntelliJ, then inside your project folder delete the ".idea" folder
- Reimport your project to IntelliJ like following: "Import Project" -> "select ONLY your build.gradle file to import". (IntelliJ will automatically grab the rest)
- build and run your application again
See official answer by IntelliJ Support:
IDEA-221673