I encountered a problem with the inability to read the configuration file while creating a spring boot project, for a small example.
A new spring boot project was created in eclipse with the following directory
We will change the application.properties, change the port number:
However, when the port number is displayed using port 8080, the configuration file information is not read:
I have found some information on the internet, some say that the configuration file is located in the wrong directory, I put the configuration file in the current directory in the new Config directory is still unable to execute.
So I wonder if it should not be placed in the directory of resources, although it is automatically built by the project.
Find some information on the Internet:
Spring boot finds application.properties files from 4 locations by default, and then puts them in the following places to rewrite the environment variables of spring boot or to define your own variables
The default 4 locations:
1./config directory under the current directory
2. Current directory
3./config directory under the Classpath
4. Classpath root directory
Note: If you have a profile in four places at once, the priority of the profile is from 1 to 4.
Confirmation of the current directory. For the current directory, you can see it when spring starts
You can read the profile information (or create a new config directory in the current directory, and put the configuration file in the Config directory) by placing the configuration file in the current directory.
This allows you to modify our configuration information when it is started, and the following changes the port to 8082:
The problem to this solution, as to why put in the resource file can not read, is still in the study, if you know the words welcome exchanges, Thank you.
This article refers to: http://www.cnblogs.com/lixuwu/p/6376194.html