application.properties

application.properties #

Your app’s properties #

When creating custom properties for your app:

  • Use app. prefix for your properties.
  • Then a category app.category ot organize easier.
  • E.g. app.user.max-per-page=50
  • E.g. app.security.type=oauth2

App info #

application.properties - use values from pom.xml
# Application name is taken from pom.xml
spring.application.name=@project.artifactId@

# Variables taken from pom.xml
info.app.name=@project.artifactId@
info.app.version=@project.version@
info.app.encoding=@project.build.sourceEncoding@
info.app.java.source=@java.version@
info.app.java.target=@java.version@

You need to enrich you pom.xml with these parts.

  • The <exclude>**/*-local.*</exclude> serves to ignore local files, like application-local.properties which might be used to override properties for the local machine.
pom.xml - requires some plugins to make the above working
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>**/*-local.*</exclude>
            </excludes>
        </resource>
    </resources>
    
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>build-info</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <delimiters>
                    <delimiter>@</delimiter>
                </delimiters>
                <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
        </plugin>
    </plugins>
</build>

You can add as well Git information :

JPA #

application.properties - jpa basic setup for external db
spring.jpa.generate-ddl=false
spring.jpa.hibernate.ddl-auto=none
spring.jpa.open-in-view=false

Logging #

application.properties - reduced logging
logging.level.org.springframework.scheduling.concurrent=warn
logging.level.org.springframework.context.support=warn
logging.level.org.springframework.boot.actuate.endpoint.web=warn
logging.level.org.springframework.data.repository.config=warn
logging.level.org.springframework.web.servlet.DispatcherServlet=warn
logging.level.org.springframework.web.context=warn
logging.level.com.zaxxer.hikari=warn
logging.level.org.apache.catalina.core.StandardService=warn
logging.level.org.apache.catalina.core.ContainerBase=warn
logging.level.org.springframework.orm.jpa=warn
logging.level.org.hibernate=warn
logging.level.liquibase=warn
logging.level.org.springframework.security=warn
logging.level.org.springframework.cloud.consul=debug