<%#
 Copyright 2013-2017 the original author or authors from the JBooter project.

 This file is part of the JBooter project, see https://jbooter.github.io/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
# ===================================================================
# Spring Boot configuration for the "dev" profile.
#
# This configuration overrides the application.yml file.
#
# More information on profiles: https://jbooter.github.io/profiles/
# More information on configuration properties: https://jbooter.github.io/common-application-properties/
# ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================
<%_ if (serviceDiscoveryType == 'eureka') { _%>

eureka:
    instance:
        prefer-ip-address: true
    client:
        <%_ if (applicationType === 'monolith') { _%>
        enabled: false # By default, the JBooter Registry is not used in the "dev" profile
        <%_ } _%>
        service-url:
            defaultZone: http://admin:${jbooter.registry.password}@localhost:8761/eureka/
<%_ } _%>

spring:
    profiles:
        active: dev
        include: swagger
    devtools:
        restart:
            enabled: true
        livereload:
            enabled: false # we use gulp + BrowserSync for livereload
    jackson:
        serialization.indent_output: true
    <%_ if (messageBroker == 'kafka' || serviceDiscoveryType == 'consul') { _%>
    cloud:
        <%_ if (serviceDiscoveryType == 'consul') { _%>
        consul:
            discovery:
               prefer-ip-address: true
            host: localhost
            port: 8500
        <%_ } _%>
        <%_ if (messageBroker == 'kafka') { _%>
        stream:
            kafka:
                binder:
                    brokers: localhost
                    zk-nodes: localhost
            bindings:
                output:
                    destination: topic-jbooter
        <%_ } _%>
    <%_ } _%>
    <%_ if (databaseType == 'sql') { _%>
    datasource:
        type: com.zaxxer.hikari.HikariDataSource
        <%_ if (devDatabaseType == 'mysql') { _%>
        url: jdbc:mysql://localhost:3306/<%= baseName %>?useUnicode=true&characterEncoding=utf8&useSSL=false
        username: root
        password:
        <%_ } else if (devDatabaseType == 'mariadb') { _%>
        url: jdbc:mariadb://localhost:3306/<%= baseName %>
        username: root
        password:
        <%_ } else if (devDatabaseType == 'postgresql') { _%>
        url: jdbc:postgresql://localhost:5432/<%= baseName %>
        username: <%= baseName %>
        password:
        <%_ } else if (devDatabaseType == 'oracle') { _%>
        url: jdbc:oracle:thin:@localhost:1521:xe
        username: system
        password: oracle
        <%_ } else if (devDatabaseType === 'mssql') { _%>
        url: jdbc:sqlserver://localhost:1433;database=<%= baseName %>
        username: SA
        password: yourStrong(!)Password
        <%_ } else if (devDatabaseType == 'h2Disk') { _%>
        url: jdbc:h2:file:./<%= BUILD_DIR %>h2db/db/<%= lowercaseBaseName %>;DB_CLOSE_DELAY=-1
        username: <%= baseName %>
        password:
        <%_ } else if (devDatabaseType == 'h2Memory') { _%>
        url: jdbc:h2:mem:<%= lowercaseBaseName %>;DB_CLOSE_DELAY=-1
        username: <%= baseName %>
        password:
        <%_ } _%>
        <%_ if (devDatabaseType == 'mysql' || devDatabaseType == 'mariadb' || devDatabaseType === 'mssql') { _%>
        hikari:
            data-source-properties:
                cachePrepStmts: true
                prepStmtCacheSize: 250
                prepStmtCacheSqlLimit: 2048
                useServerPrepStmts: true
        <%_ } _%>
    <%_ if (devDatabaseType == 'h2Disk' || devDatabaseType == 'h2Memory') { _%>
    h2:
        console:
            enabled: false
    <%_ } _%>
    jpa:
        <%_ if (devDatabaseType == 'mysql' || devDatabaseType == 'mariadb') { _%>
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
        <%_ } else if (devDatabaseType == 'postgresql') { _%>
        database-platform: io.github.jbooter.domain.util.FixedPostgreSQL82Dialect
        <%_ } else if (devDatabaseType == 'oracle') { _%>
        database-platform: org.hibernate.dialect.Oracle12cDialect
        <%_ } else if (devDatabaseType === 'mssql') { _%>
        database-platform: org.hibernate.dialect.SQLServer2012Dialect
        <%_ } else { _%>
        database-platform: io.github.jbooter.domain.util.FixedH2Dialect
        <%_ } _%>
        <%_ if (devDatabaseType == 'mysql' || devDatabaseType === 'mariadb') { _%>
        database: MYSQL
        <%_ } else if (devDatabaseType == 'postgresql') { _%>
        database: POSTGRESQL
        <%_ } else if (devDatabaseType == 'oracle') { _%>
        database: ORACLE
        <%_ } else if (devDatabaseType === 'mssql') { _%>
        database: SQL_SERVER
        <%_ } else { _%>
        database: H2
        <%_ } _%>
        show-sql: true
        properties:
            hibernate.id.new_generator_mappings: true
            hibernate.cache.use_second_level_cache: <% if (hibernateCache == 'ehcache' || hibernateCache == 'hazelcast') { %>true<% } else { %>false<% } %>
            hibernate.cache.use_query_cache: false
            hibernate.generate_statistics: true
            <%_ if (hibernateCache == 'ehcache') { _%>
            hibernate.cache.region.factory_class: io.github.jbooter.config.jcache.NoDefaultJCacheRegionFactory
            <%_ } else if (hibernateCache == 'hazelcast') { _%>
            hibernate.cache.region.factory_class: com.hazelcast.hibernate.HazelcastCacheRegionFactory
            hibernate.cache.hazelcast.instance_name: <%= baseName %>
            <%_ } _%>
            <%_ if (hibernateCache == 'hazelcast') { _%>
            hibernate.cache.use_minimal_puts: true
            hibernate.cache.hazelcast.use_lite_member: true
            <%_ } _%>
    <%_ } _%>
    <%_ if (databaseType == 'mongodb' || databaseType == 'cassandra' || applicationType == 'gateway' || searchEngine == 'elasticsearch') { _%>
    data:
    <%_ } _%>
    <%_ if (databaseType == 'mongodb') { _%>
        mongodb:
            uri: mongodb://localhost:27017
            database: <%= baseName %>
    <%_ } _%>
    <%_ if (databaseType == 'cassandra') { _%>
        cassandra:
            contactPoints: localhost
            protocolVersion: V4
            compression: LZ4
            keyspaceName: <%= baseName %>
    <%_ } _%>
    <%_ if (searchEngine == 'elasticsearch') { _%>
        elasticsearch:
            cluster-name:
            cluster-nodes:
            properties:
                path:
                    logs: <%= BUILD_DIR %>elasticsearch/log
                    data: <%= BUILD_DIR %>elasticsearch/data
    <%_ } _%>
    mail:
        host: localhost
        port: 25
        username:
        password:
    messages:
        cache-seconds: 1
    thymeleaf:
        cache: false
<%_ if (serviceDiscoveryType || applicationType === 'gateway' || applicationType === 'microservice' || applicationType === 'uaa') { _%>
    zipkin: # Use the "zipkin" Maven profile to have the Spring Cloud Zipkin dependencies
        base-url: http://localhost:9411
        enabled: false
        locator:
            discovery:
                enabled: true
<%_ } _%>
<%_ if (databaseType === 'sql') { _%>

liquibase:
    contexts: dev
<%_ } _%>

# ===================================================================
# To enable SSL, generate a certificate using:
# keytool -genkey -alias <%= baseName %> -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
#
# You can also use Let's Encrypt:
# https://maximilian-boehm.com/hp2121/Create-a-Java-Keystore-JKS-from-Let-s-Encrypt-Certificates.htm
#
# Then, modify the server.ssl properties so your "server" configuration looks like:
#
# server:
#    port: 8443
#    ssl:
#        key-store: keystore.p12
#        key-store-password: <your-password>
#        keyStoreType: PKCS12
#        keyAlias: <%= baseName %>
# ===================================================================
server:
    port: <%= serverPort %>

# ===================================================================
# JBooter specific properties
#
# Full reference is available at: https://jbooter.github.io/common-application-properties/
# ===================================================================

jbooter:
    <%_ if (applicationType == 'gateway') { _%>
    gateway:
        rate-limiting:
            enabled: false
            limit: 100000
            duration-in-seconds: 3600
        authorized-microservices-endpoints: # Access Control Policy, if left empty for a route, all endpoints will be accessible
            app1: /api,/v2/api-docs # recommended dev configuration
    <%_ } _%>
    http:
        version: V_1_1 # To use HTTP/2 you will need SSL support (see above the "server.ssl" configuration)
    <%_ if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast' ||  hibernateCache == 'ehcache') { _%>
    cache: # Cache configuration
        <%_ if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast') { _%>
        hazelcast: # Hazelcast distributed cache
            time-to-live-seconds: 3600
            backup-count: 1
        <%_ } _%>
        <%_ if (hibernateCache == 'ehcache') { _%>
        ehcache: # Ehcache configuration
            time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
            max-entries: 100 # Number of objects in each cache entry
        <%_ } _%>
    <%_ } _%>
    # CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
    cors:
        allowed-origins: "*"
        allowed-methods: GET, PUT, POST, DELETE, OPTIONS
        allowed-headers: "*"
        exposed-headers:
        allow-credentials: true
        max-age: 1800
    <%_ if (authenticationType == 'jwt') { _%>
    security:
        authentication:
            jwt:
                secret: my-secret-token-to-change-in-production
                # Token is valid 24 hours
                token-validity-in-seconds: 86400
                token-validity-in-seconds-for-remember-me: 2592000
    <%_ } _%>
    <%_ if ((applicationType === 'microservice' || applicationType === 'uaa') && authenticationType === 'uaa') { _%>
    security:
        client-authorization:
            <%_ if (applicationType !== 'uaa') { _%>
            access-token-uri: http://<%= uaaBaseName.toLowerCase() %>/oauth/token
            token-service-id: <%= uaaBaseName.toLowerCase() %>
            <%_ } _%>
            client-id: internal
            client-secret: internal
    <%_ } _%>
    <%_ if (authenticationType == 'oauth2' && databaseType != 'sql') { _%>
    security:
        authentication:
            oauth:
                client-id: <%= baseName %>app
                client-secret: my-secret-token-to-change-in-production
                # Token is valid 30 minutes
                token-validity-in-seconds: 1800
    <%_ } _%>
<%_ if (authenticationType == 'session') { _%>
    security:
        remember-me:
            # security key (this key should be unique for your application, and kept secret)
            key: <%= rememberMeKey %>
<%_ } _%>
    mail: # specific JBooter mail property, for standard properties see MailProperties
        from: <%= baseName %>@localhost
        base-url: http://127.0.0.1:<%= serverPort %>
    metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
        jmx.enabled: true
        graphite: # Use the "graphite" Maven profile to have the Graphite dependencies
            enabled: false
            host: localhost
            port: 2003
            prefix: <%= baseName %>
        prometheus: # Use the "prometheus" Maven profile to have the Prometheus dependencies
            enabled: false
            endpoint: /prometheusMetrics
        logs: # Reports Dropwizard metrics in the logs
            enabled: false
            report-frequency: 60 # in seconds
    logging:
        logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
            enabled: false
            host: localhost
            port: 5000
            queue-size: 512
    <%_ if (applicationType == 'microservice' || applicationType == 'gateway') { _%>
        spectator-metrics: # Reports Spectator Circuit Breaker metrics in the logs
            enabled: false
            # edit spring.metrics.export.delay-millis to set report frequency
    <%_ } _%>

# ===================================================================
# Application specific properties
# Add your own application properties here, see the ApplicationProperties class
# to have type-safe configuration, like in the JBooterProperties above
#
# More documentation is available at:
# https://jbooter.github.io/common-application-properties/
# ===================================================================

application:
