Spring Boot JPA/Data Properties

Spring Boot JPA/Data properties that can be configured with any Spring Boot Application where need to access database. These properties are already configured in Spring Boot with the given default value.

Note: In your application, You don’t need to add all these values in your application.proprties / application.yaml file. You just need to add only those values which you want to change/override.

See Also:

You can follow specific Spring Boot Configuration properties link for based on your data source.

  • Database/Data Source Configuration Properties
  • JPA Configuration Properties
  • JTA Configuration Properties

DAO Configuration Properties

Spring Boot load these properties in PersistenceExceptionTranslationAutoConfiguration class.

NameDefault ValueDescription
spring.dao.exceptiontranslation.enabledtrueEnable the PersistenceExceptionTranslationPostProcessor.

DataSource Configuration Properties

Spring Boot load these properties in DataSourceAutoConfiguration & DataSourceProperties class.

NameDefault ValueDescription
spring.datasource.continue-on-errorfalseDo not stop if an error occurs while initializing the database.
spring.datasource.data Data (DML) script resource reference.
spring.datasource.data-username database usename to execute DML scripts (if different).
spring.datasource.data-password database password to execute DML scripts (if different).
spring.datasource.dbcp.* Commons DBCP specific settings
spring.datasource.dbcp2.* Commons DBCP2 specific settings
spring.datasource.driver-class-name Fully qualified JDBC driver name. if not set detect from URL by default.
spring.datasource.generate-unique-namefalseGenerate a random datasource name.
spring.datasource.hikari.* Hikari specific settings
spring.datasource.initializetrueallow to execute query using ‘data.sql’.
spring.datasource.jmx-enabledfalseEnable JMX support (if underlying pool provided).
spring.datasource.jndi-name JNDI location of the datasource other set fields( Class, url, username & password) are ignored when set.
spring.datasource.nametestdbdatasource name.
spring.datasource.password database login password.
spring.datasource.platformallPlatform to use in the schema resource (schema-${platform}.sql).
spring.datasource.schema Schema (DDL) script resource reference.
spring.datasource.schema-username database user to execute DDL scripts (if different).
spring.datasource.schema-password database password to execute DDL scripts (if different).
spring.datasource.separator;Statement separator in SQL initialization scripts.
spring.datasource.sql-script-encoding SQL scripts encoding.
spring.datasource.tomcat.* Tomcat datasource specific settings
spring.datasource.type connection pool fully qualified name implementation to use. if not set by default detected from the classpath.
spring.datasource.url JDBC database url.
spring.datasource.username database user.
spring.datasource.xa.data-source-class-name fully qualified name of XA data source.
spring.datasource.xa.properties Properties to pass to the XA data source.

JPA Configuration Properties

Spring Boot load these properties in JpaBaseConfiguration and HibernateJpaAutoConfiguration class.

NameDefault ValueDescription
spring.data.jpa.repositories.enabledtrueEnable JPA repositories.
spring.jpa.database Target database to operate on. It detected by default or alternatively set using the “databasePlatform” property.
spring.jpa.database-platform Name of the target database to operate on. It detected by default or alternatively set using the “Database” enum.
spring.jpa.generate-ddlfalseInitialize the schema on startup.
spring.jpa.hibernate.ddl-auto DDL mode for the “hibernate.hbm2ddl.auto” property. Default value is “create-drop” when using an embedded database otherwise “none”.
spring.jpa.hibernate.naming.implicit-strategy Hibernate 5 implicit fully qualified naming strategy name .
spring.jpa.hibernate.naming.physical-strategy Hibernate 5 physical fully qualified naming strategy name .
spring.jpa.hibernate.naming.strategy Hibernate 4 fully qualified naming strategy name. Not supported with Hibernate 5.
spring.jpa.hibernate.use-new-id-generator-mappings Use Hibernate’s IdentifierGenerator for AUTO, TABLE and SEQUENCE.
spring.jpa.open-in-viewtrueRegister OpenEntityManagerInViewInterceptor. Binds a JPA EntityManager to the thread for request entire processing.
spring.jpa.properties.* Additional native properties set on JPA provider.
spring.jpa.show-sqlfalseEnable SQL statements logging.

JTA Configuration Properties

Spring Boot load these properties in JtaAutoConfiguration class.

NameDefault ValueDescription
spring.jta.enabledtrueEnable JTA support.
spring.jta.log-dir Transaction logs directory.
spring.jta.transaction-manager-id Transaction manager unique identifier.

Data REST Configuration Properties

Spring Boot load these properties in RepositoryRestProperties class.

NameDefault ValueDescription
spring.data.rest.base-path Base path for Spring Data REST to repository resources.
spring.data.rest.default-page-size Default page size.
spring.data.rest.enable-enum-translation Enable enum value translation through Spring Data REST by default resource bundle.
spring.data.rest.limit-param-name URL query parameter name that decide how many results return at once.
spring.data.rest.max-page-size Maximum size of pages.
spring.data.rest.page-param-name URL query string parameter to indicates what page to return.
spring.data.rest.return-body-on-create Return a response body after creating an entity.
spring.data.rest.return-body-on-update Return a response body after updating an entity.
spring.data.rest.sort-param-name URL query string parameter to indicates what direction to sort results.

H2 Web Console Configuration Properties

Spring Boot load these properties in H2ConsoleProperties class.

NameDefault ValueDescription
spring.h2.console.enabledfalseEnable the console.
spring.h2.console.path/h2-consolePath at which the console will be available.
spring.h2.console.settings.tracefalseEnable trace output.
spring.h2.console.settings.web-allow-othersfalseEnable remote access.

Data Redis Configuration Properties

Spring Boot load these properties in SecurityProperties class.

NameDefault ValueDescription
spring.data.redis.repositories.enabledtrueEnable Redis repositories.

Redis Configuration Properties

Spring Boot load these properties in RedisProperties class.

NameDefault ValueDescription
spring.redis.cluster.max-redirects Maximum number of redirects to follow when executing commands across the cluster.
spring.redis.cluster.nodes Comma-separated list of “host:port” pairs to bootstrap from.
spring.redis.database0Database index used by the connection factory.
spring.redis.hostlocalhostRedis server host.
spring.redis.password Login password of the redis server.
spring.redis.pool.max-active8Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.pool.max-idle8Max number of “idle” connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.pool.max-wait-1Maximum time a connection allocation to block before throwing an exception in case of pool is exhausted. Use -1 to block indefinitely.
spring.redis.pool.min-idle0Minimum number of idle connections in pool. This works only when set as positive.
spring.redis.port6379Redis server port.
spring.redis.sentinel.master Name of Redis server.
spring.redis.sentinel.nodes Comma-separated host:port pairs.
spring.redis.timeout0Connection timeout (milliseconds).

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s