Javatpoint Logo
Javatpoint Logo

Spring Boot Application Properties

Spring Boot provides various properties which can be specified inside our project's application.properties file. These properties have default values and you can set that inside the properties file. Properties are used to set values like: server-port number, database connection configuration etc.

The following table contains common Spring Boot properties.

Property Default value Description
banner.charset UTF-8 It is used to set banner file encoding.
banner.location classpath:banner.txt It is used to set banner file location.
logging.file It is used to set log file name. For example data.log.
spring.application.index It is used to set application index.
spring.application.name It is used to set application name.
spring.application.admin.enabled false It is used to enable admin features for the application.
spring.config.location It is used to config file locations.
spring.config.name application It is used to set config file name.
spring.mail.default-encoding UTF-8 It is used to set default MimeMessage encoding.
spring.mail.host It is used to set SMTP server host. For example smtp.example.com.
spring.mail.password It is used to set login password of the SMTP server.
spring.mail.port It is used to set SMTP server port.
spring.mail.test-connection false It is used to test that the mail server is available on startup.
spring.mail.username It is used to set login user of the SMTP server.
spring.main.sources It is used to set sources for the application.
server.address It is used to set network address to which the server should bind to.
server.connection-timeout It is used to set time in milliseconds that connectors will wait for another HTTP request before closing the connection.
server.context-path It is used to set context path of the application.
server.port 8080 It is used to set HTTP port.
server.server-header It is used for the Server response header (no header is sent if empty)
server.servlet-path / It is used to set path of the main dispatcher servlet
server.ssl.enabled It is used to enable SSL support.
spring.http.multipart.enabled True It is used to enable support of multi-part uploads.
spring.http.multipart.max-file-size 1MB It is used to set max file size.
spring.mvc.async.request-timeout It is used to set time in milliseconds.
spring.mvc.date-format It is used to set date format. For example dd/MM/yyyy.
spring.mvc.locale It is used to set locale for the application.
spring.social.facebook.app-id It is used to set application's Facebook App ID.
spring.social.linkedin.app-id It is used to set application's LinkedIn App ID.
spring.social.twitter.app-id It is used to set application's Twitter App ID.
security.basic.authorize-mode role It is used to set security authorize mode to apply.
security.basic.enabled true It is used to enable basic authentication.

Spring Boot Example

In this example, we are creating properties file and setting server port.

We have following files in our Spring Boot project.

// pom.xml

// HomeController.java

// SpringBootExampleApplication.java

// application.properties

Our project structure looks like the below.

Spring Boot application properties 1

Output:

After running the application, it produces the following output.

Spring Boot application properties 2

You can see that this application is running on port 2017.

Same like, we can set other properties also for our Spring Boot application.






Please Share

facebook twitter google plus pinterest tumbler

Learn Latest Tutorials