English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Spring Boot Framework comes with built-in mechanisms to use application.properties for application configuration. It is located at src/main/resources as shown in the figure below.
Spring Boot provides files that can be application.properties various properties in the file. These properties have default values. We can set one or more properties for the Spring Boot application. Spring Boot also allows us to define our own properties as needed.
The application.properties file allows us to Run applications in different environments. In short, we can use the application.properties file to perform the following operations:
Configure the Spring Boot framework Define our application custom configuration properties
#Configure application name pring.application.name = demoApplication #Configure port server.port = 8081
In the above example, we have already configured application nameand Port. Port8081Indicates that the application is running on port 8081 running on.
YAML properties file
Spring Boot provides another file for configuring properties, called yml file. The Yaml file takes effect because there is Snake YAML jar. In addition to using the application.properties file, we can also use the application.yml file, but Yml The file should appear in the classpath.
application example.yml
spring: application: name: demoApplication server: port: 8081
In the above example, we have already configured application nameand Port. Port8081Indicates that the application is running on port 8081 running on.
There are 16The categories of Spring Boot properties are as follows:
Core properties Cache properties Email properties JSON properties Data properties Transaction properties Data migration properties Integration properties Network media resources Template properties Server properties Security properties RSocket properties Executor properties DevTools properties Test properties
The following table provides a list of common Spring Boot properties:
Property | Default value | Description |
Debug | false | It enables debug logs. |
spring.application.name | It is used to set the application name. | |
spring.application.admin.enabled | false | It is used to enable the management features of the application. |
spring.config.name | application | Used to set the configuration file name. |
spring.config.location | It is used to configure the file name. | |
server.port | 8080 | Configure the HTTP server port |
server.servlet.context-path | It configures the context path of the application. | |
logging.file.path | It configures the location of the log file. | |
spring.banner.charset | UTF-8 | Banner file encoding. |
spring.banner.location | classpath: banner.txt | It is used to set the location of the title file. |
logging.file | It is used to set the log file name. For example, data.log. | |
spring.application.index | It is used to set the application index. | |
spring.application.name | It is used to set the application name. | |
spring.application.admin.enabled | false | It is used to enable management features for the application. |
spring.config.location | It is used to configure the file location. | |
spring.config.name | application | It is used to set the filename. |
spring.mail.default-encoding | UTF-8 | It is used to set the default encoding for MimeMessage. |
spring.mail.host | It is used to set the SMTP server host. For example, smtp.example.com. | |
spring.mail.password | It is used to set the login password for the SMTP server. | |
spring.mail.port | It is used to set the SMTP server port. | |
spring.mail.test-connection | false | It is used to test if the mail server is available at startup. |
spring.mail.username | It is used to set the login username for the SMTP server. | |
spring.main.sources | It is used to set the source of the application. | |
server.address | It is used to set the network address that the server should bind to. | |
server.connection-timeout | It is used to set the time (in milliseconds) that the connector will wait for another HTTP request before closing the connection. | |
server.context-path | It is used to set the context path of the application. | |
server.port | 8080 | It is used to set the HTTP port. |
server.server-header | It is used for server response headers (if empty, headers will not be sent). | |
server.servlet-path | / | It is used to set the path of the main scheduler servlet. |
server.ssl.enabled | It is used to enable SSL support. | |
spring.http.multipart.enabled | true | It is used to enable support for chunked uploads. |
spring.servlet.multipart.max-File size | 1MB | It is used to set the maximum file size. |
spring.mvc.async.request-timeout | It is used to set the time (in milliseconds). | |
spring.mvc.date-format | It is used to set the date format. For example, dd/MM/yyyy. | |
spring.mvc.locale | It is used to set the language environment of the application. | |
spring.social.facebook.app-id | It is used to set the Facebook App ID of the application. | |
spring.social.linkedin.app-id | It is used to set the LinkedIn Application ID for the application. | |
spring.social.twitter.app-id | It is used to set the Twitter App ID for the application. | |
security.basic.authorize-mode | role | It is used to set the security authorization mode to be applied. |
security.basic.enabled | true | It is used to enable basic authentication. |
Spring.test.database.replace | any | Type of Existing DataSource to Replace. |
Spring.test.mockmvc.print | default | MVC Print Options |
spring.freemaker.content-type | text/html | Content Type Value |
server.server-header | Value for Server Response Headers. | |
spring.security.filter.dispatcher-type | async, error, request | Security Filter Chain Dispatcher Type. |
spring.security.filter.order | -100 | Security Filter Chain Order. |
spring.security.oauth2.client.registration.* | OAuth Client Registration. | |
spring.security.oauth2.client.provider.* | OAuth Provider Details. |