Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我看见namespace里可以建yml配置文件,但是好像用不了 #1113

Closed
liu12qw opened this issue May 15, 2018 · 8 comments
Closed

我看见namespace里可以建yml配置文件,但是好像用不了 #1113

liu12qw opened this issue May 15, 2018 · 8 comments

Comments

@liu12qw
Copy link

liu12qw commented May 15, 2018

 yml里一大串的配置,那个yml转prop的在线工具不好用,网上也没找到好用的工具,哎,一个yml转了我半个多小时!
我看见namespace里可以选择yml类型,试了一下,client可以下载到本地(配置namespace的时候要加上yml后缀才行);但是好像并不能解析里面的变量,项目启不来;
请问新增namespace类型为yml,暂时没有用的么?
@nobodyiam
Copy link
Member

namespace为yml的,现在是需要客户端通过ConfigService.getConfigFile后自己解析的。

yml转prop的工具不好用吗?你的yml有比较高级的写法?

@liu12qw
Copy link
Author

liu12qw commented May 15, 2018

也不高级,和下面这个差不多吧,就是转后结果要手动修改;

spring:
    devtools:
        restart:
            enabled: false
        livereload:
            enabled: false
    application:
        name: danti
    profiles:
        active: prod
    jackson:
        serialization.write_dates_as_timestamps: false
    messages:
        basename: i18n/messages
    mvc:
        favicon:
            enabled: false
    thymeleaf:
        mode: XHTML
        cache: true
    social:
        google:
            client-id: xxx
            client-secret: xxx

        facebook:
            client-id: xxx
            client-secret: xxx

        twitter:
            client-id: xxx
            client-secret: xxx
    datasource:
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:mysql://localhost:3306/dantiProd?useUnicode=true&characterEncoding=utf8&useSSL=false
        username: root
        password: mysql
        hikari:
            data-source-properties:
                cachePrepStmts: true
                prepStmtCacheSize: 250
                prepStmtCacheSqlLimit: 2048
                useServerPrepStmts: true
    jpa:
        open-in-view: false
        hibernate:
            ddl-auto: none
            naming:
                physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
                implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
        database: MYSQL
        show-sql: false
        properties:
            hibernate.id.new_generator_mappings: true
            hibernate.cache.use_second_level_cache: true
            hibernate.cache.use_query_cache: false
            hibernate.generate_statistics: false
            hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory
    data:
        elasticsearch:
            cluster-name:
            cluster-nodes:
            properties:
                path:
                    logs: target/elasticsearch/log
                    data: target/elasticsearch/data
    mail:
        host: localhost
        port: 25
        username:
        password:

转后的结果

spring.devtools.restart.enabled=false
spring.devtools.livereload.enabled=false
spring.application.name=danti
spring.profiles.active=prod
spring.jackson.serialization.write_dates_as_timestamps=false
spring.jackson.messages.basename=i18n/messages
spring.jackson.mvc.favicon.enabled=false
spring.jackson.thymeleaf.mode=XHTML
spring.jackson.thymeleaf.cache=true
spring.jackson.social.google.client-id=xxx
spring.jackson.social.google.client-secret=xxx
spring.jackson.social.facebook.client-id=xxx
spring.jackson.social.facebook.client-secret=xxx
spring.jackson.social.twitter.client-id=xxx
spring.jackson.social.twitter.client-secret=xxx
spring.jackson.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.jackson.datasource.url=jdbc:mysql://localhost:3306/dantiProd?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.jackson.datasource.username=root
spring.jackson.datasource.password=mysql
spring.jackson.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.jackson.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.jackson.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.jackson.datasource.hikari.data-source-properties.useServerPrepStmts=true
spring.jackson.jpa.open-in-view=false
spring.jackson.jpa.hibernate.ddl-auto=none
spring.jackson.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
spring.jackson.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
spring.jackson.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jackson.jpa.database=MYSQL
spring.jackson.jpa.show-sql=false
spring.jackson.jpa.properties.hibernate.id.new_generator_mappings=true
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.use_second_level_cache=true
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.use_query_cache=false
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.generate_statistics=false
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.cache.region.factory_class=io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.data.elasticsearch.cluster-name=
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.data.elasticsearch.cluster-nodes=
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.data.elasticsearch.properties.path.logs=target/elasticsearch/log
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.data.elasticsearch.properties.path.data=target/elasticsearch/data
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.mail.host=localhost
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.mail.port=25
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.mail.username=
spring.jackson.jpa.properties.hibernate.id.hibernate.cache.hibernate.cache.hibernate.hibernate.mail.password=

@nobodyiam
Copy link
Member

看了下,你的yml写的貌似不太标准,hibernate那块改一下就支持了

org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
        database: MYSQL
        show-sql: false
        properties:
            hibernate:
                id.new_generator_mappings: true
            hibernate:
                cache:
                     use_second_level_cache: true
                     use_query_cache: false
                     region:
                         factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory
                generate_statistics: false

@wenchongyang
Copy link

wenchongyang commented May 17, 2018

list:
  - lang: cn
    rules:
      - currencyArray: ["a","b"]
        position: 1
        blank: 0
     - currencyArray: ["c","d"]
       position: 2
       blank: 3

这种转prop就没的转了。

@xiaoyangdeve
Copy link

liu12qw @liu12qw
你是怎么把yml转成properties形式的。求分享

@jieqian
Copy link

jieqian commented May 23, 2018

@LucienMoMo 欢迎使用我写的maven插件
https://github.com/jieqian/y2p-maven-plugin

@nobodyiam
Copy link
Member

我新开了一个PR #1944,支持yml类型的namespace注入到Spring中去,大家可以看一下~

@nobodyiam
Copy link
Member

1.3.0版本已经发布,支持了Yml/Yaml格式的namespace和Spring/Spring Boot集成。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants