JHipster - 常用应用程序属性

JHipster生成一个Spring Boot应用程序,并且可以使用标准的Spring Boot属性机制进行配置。

这些属性由JHipster在生成时配置,并且在开发和生产模式中通常具有不同的值:在我们的配置文件文档中了解更多信息。

在JHipster应用程序中,有三种属性:

  1. Spring Boot标准应用程序属性
  2. JHipster应用程序属性
  3. 应用程序特定的属性

Spring Boot标准应用程序属性

像任何Spring Boot应用程序一样,JHipster允许您配置任何标准的Spring Boot应用程序属性

JHipster应用程序属性

JHipster提供了来自JHipster服务器端库的特定应用程序属性。这些属性是所有JHipster项目的标准属性,但其中一些属性仅适用于您构建应用程序时选择的内容:例如,jhipster.cache.hazelcast如果您选择Hazelcast作为第二级Hibernate缓存,则此项仅适用。

这些属性使用io.github.jhipster.config.JHipsterProperties该类进行配置。

以下是这些属性的文档:

jhipster:

    # Thread pool that will be used for asynchronous method calls in JHipster
    async:
        core-pool-size: 2 # Initial pool size
        max-pool-size: 50 # Maximum pool size
        queue-capacity: 10000 # Queue capacity of the pool

    # Specific configuration for JHipster gateways
    # See https://www.jhipster.tech/api-gateway/ for more information on JHipster gateways
    gateway:
        rate-limiting:
            enabled: false # Rate limiting is disabled by default
            limit: 100_000L # By default we allow 100,000 API calls
            duration-in-seconds: 3_600 # By default the rate limiting is reinitialized every hour
        authorized-microservices-endpoints: # Access Control Policy, if left empty for a route, all endpoints will be accessible
            app1: /api # recommended prod configuration, it allows the access to all API calls from the "app1" microservice

    # HTTP configuration
    http:
        # V_1_1 for HTTP/1.1 or V_2_0 for HTTP/2.
        # To use HTTP/2 you will need SSL support (see the Spring Boot "server.ssl" configuration)
        version: V_1_1
        #Force the server cipher suite to follow the exact order specifying in server.ssl.ciphers (For perfect forward secrecy)
        useUndertowUserCipherSuitesOrder: true
        cache: # Used by io.github.jhipster.web.filter.CachingHttpHeadersFilter
            timeToLiveInDays: 1461 # Static assets are cached for 4 years by default

    # Hibernate 2nd level cache, used by CacheConfiguration
    cache:
        hazelcast: # Hazelcast configuration
            time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
            backup-count: 1 # Number of objects backups
            # Configure the Hazelcast management center
            # Full reference is available at: http://docs.hazelcast.org/docs/management-center/3.9/manual/html/Deploying_and_Starting.html
            management-center:
                enabled: false # Hazelcast management center is disabled by default
                update-interval: 3 # Updates are sent to the Hazelcast management center every 3 seconds by default
                # Default URL for Hazelcast management center when using JHipster's Docker Compose configuration
                # See src/main/docker/hazelcast-management-center.yml
                # Warning, the default port is 8180 as port 8080 is already used by JHipster
                url: http://localhost:8180/mancenter
        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
        infinispan: #Infinispan configuration
            config-file: default-configs/default-jgroups-tcp.xml
            # local app cache
            local:
                time-to-live-seconds: 60 # By default objects stay 1 hour (in minutes) in the cache
                max-entries: 100 # Number of objects in each cache entry
            #distributed app cache
            distributed:
                time-to-live-seconds: 60 # By default objects stay 1 hour (in minutes) in the cache
                max-entries: 100 # Number of objects in each cache entry
                instance-count: 1
            #replicated app cache
            replicated:
                time-to-live-seconds: 60 # By default objects stay 1 hour (in minutes) in the cache
                max-entries: 100 # Number of objects in each cache entry

    # E-mail properties
    mail:
        from: jhipster@localhost # The default "from" address for e-mails
        base-url: http://127.0.0.1:8080 # URL to the application, used inside e-mails

    # Spring Security specific configuration
    security:
        remember-me: # JHipster secure implementation of the remember-me mechanism, for session-based authentication
            # security key (this key should be unique for your application, and kept secret)
            key: 0b32a651e6a65d5731e869dc136fb301b0a8c0e4
        client-authorization: # Used with JHipster UAA authentication
            access-token-uri: # URL of the JHipster UAA server OAuth tokens
            token-service-id: # ID of the current application
            client-id: # OAuth client ID
            client-secret: # OAuth client secret
        authentication:
            jwt: # JHipster specific JWT implementation
                secret: # JWT secret key
                token-validity-in-seconds: 86400 # Token is valid 24 hours
                token-validity-in-seconds-for-remember-me: 2592000 # Remember me token is valid 30 days

    # Swagger configuration
    swagger:
        default-include-pattern: /api/.*
        title: JHipster API
        description: JHipster API documentation
        version: 0.0.1
        terms-of-service-url:
        contact-name:
        contact-url:
        contact-email:
        license:
        license-url:
        host:
        protocols:

    # DropWizard Metrics configuration, used by MetricsConfiguration
    metrics:
        jmx: # Export metrics as JMX beans
            enabled: true # JMX is enabled by default
        # Send metrics to a Graphite server
        # Use the "graphite" Maven profile to have the Graphite dependencies
        graphite:
            enabled: false # Graphite is disabled by default
            host: localhost
            port: 2003
            prefix: jhipster
        # Send metrics to a Prometheus server
        # Use the "prometheus" Maven profile to have the Prometheus dependencies
        prometheus:
            enabled: false # Prometheus is disabled by default
            endpoint: /prometheusMetrics
        logs: # Reports Dropwizard metrics in the logs
            enabled: false
            reportFrequency: 60 # frequency of reports in seconds

    # Logging configuration, used by LoggingConfiguration
    logging:
        logstash: # Forward logs to Logstash over a socket
            enabled: false # Logstash is disabled by default
            host: localhost # Logstash server URL
            port: 5000 # Logstash server port
            queue-size: 512 # Queue for buffering logs
        spectator-metrics: # Reports Netflix Spectator metrics in the logs
            enabled: false # Spectator is disabled by default

    # By default cross-origin resource sharing (CORS) is enabled in "dev" mode for
    # monoliths and gateways.
    # It is disabled by default in "prod" mode for security reasons, and for microservices
    # (as you are supposed to use a gateway to access them).
    # This configures a standard org.springframework.web.cors.CorsConfiguration
    # Note that "exposed-headers" is mandatory for JWT-based security, which uses
    # the "Authorization" header, and which is not a default exposed header.
    cors:
        allowed-origins: "*"
        allowed-methods: "*"
        allowed-headers: "*"
        exposed-headers: "Authorization"
        allow-credentials: true
        max-age: 1800

    # Ribbon displayed on the top left-hand side of JHipster applications
    ribbon:
        # Comma-separated list of profiles that display a ribbon
        display-on-active-profiles: dev

应用程序特定的属性

您生成的应用程序也可以拥有自己的Spring Boot属性。这是强烈推荐的,因为它允许应用程序的类型安全配置,以及IDE中的自动完成和文档。

JHipster已经产生了ApplicationProperties在类config包,它已经被预先配置,并且它在底部的已经记录的application.ymlapplication-dev.ymlapplication-prod.yml文件。你所需要做的就是编写你自己的特定属性。

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页