List of properties available for in Spring Boot?

By : zeodtr

Spring Boot document says that we can set properties in file.
But I cannot find a document that lists available properties that can be set.
Where can I find such a document?

For example, I want to set documentRoot for embedded servlet.
I found that the setDocumentRoot() method is implemented in
But I don't know when or where to call the method, or the name of property that can be set in
I think it should be easy, since Spring Boot's very purpose is to ease the configuration.

Thanks in advance.


As M. Deinum sugggested, I added 'server.document-root: someDirectoryName' to the, but following error occured.

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'document-root' of bean class []: Bean property 'document-root' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(
    at org.springframework.validation.DataBinder.applyPropertyValues(
    at org.springframework.validation.DataBinder.doBind(
    at org.springframework.boot.bind.RelaxedDataBinder.doBind(
    at org.springframework.validation.DataBinder.bind(
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(
    ... 31 more

I think it is because of the way implemented. (See

It declares '@ConfigurationProperties(name = "server", ignoreUnknownFields = false)'. So, it manages the application properties that starts with 'server', and disallowes unknown property name.
And it does not support documentRoot getter/setter.

BTW, ServerProperties class is made to a Bean by org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration (See so that it can participate in the configuration process.

So, I tried to implement ServerProperties-like one and ServerPropertiesAutoConfiguration-like one myself.
The code is as follows:

package com.sample.server;


import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class SampleConfiguration
    public SampleServerProperties sampleServerProperties()
        return new SampleServerProperties();

    @ConfigurationProperties(name = "sample.server")
    public static class SampleServerProperties
        implements EmbeddedServletContainerCustomizer 
        private String documentRoot;
        public String getDocumentRoot()
            return documentRoot;
        public void setDocumentRoot(String documentRoot)
            System.out.println("############## setDocumentRoot");
            this.documentRoot = documentRoot;

        public void customize(ConfigurableEmbeddedServletContainerFactory factory)
            if (getDocumentRoot() != null)
                factory.setDocumentRoot(new File(getDocumentRoot()));

And added following line to

sample.server.documentRoot: someDirectoryName

...And it works!

"############## setDocumentRoot" is printed to the console, and the document root is actually set.

So, I'm happy now, but is this the right way to do it?

By : zeodtr


Your question is very appropriate. I found an alternative simpler solution, when I was looking for ajp configuration ( :

set in


in your application class:

1) put the property using @Value annotiation

String documentRoot;

2) and add the bean

public EmbeddedServletContainerFactory servletContainer() {

    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();

    if (StringUtils.isNotBlank(documentRoot)) {
        tomcat.setDocumentRoot(new File(documentRoot));

    return tomcat;

you are done!

This video can help you solving your question :)
By: admin