Troubleshooting Eclipse Create Spring Boot project does not load application.properties configuration file

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.