从模块编辑 jhipster 的 application.yml

Edit application.yml of jhipster from module

我创建了一个用于集成 rabbitmq 的 jhipster 模块。

当我安装模块时,模块通过以下方式为我添加了 pom 中的依赖项:

        this.addMavenDependency("org.springframework.cloud", "spring-cloud-starter-stream-rabbit");
        this.addMavenDependency("org.springframework.cloud", "spring-cloud-starter-sleuth");
        this.addMavenDependency("org.springframework.boot", "spring-boot-starter-cache");

当我重新生成实体时,模块会创建发布者和渠道 class。

到这里一切都很好,但我需要在 application.yml 中添加 chennel confing! 在 BaseGenerator 或其他部分中是否存在一个函数,例如用于在 application.yml 中添加配置的 addMavenDependency?

提前谢谢

最后我没有使用标准方法,而是使用 js-yaml 库工作

            const yaml = require('js-yaml');

...

            let configFile = 'src/main/resources/config/application-exchanges.yml';
            let doc = yaml.load(fs.readFileSync(configFile, 'utf8'));
            
            if(!doc) {
                doc = {};
            }
            if(!doc.spring) {
                doc.spring = {};
            }
            if(!doc.spring.cloud) {
                doc.spring.cloud = {};
            }
            if(!doc.spring.cloud.stream) {
                doc.spring.cloud.stream = {};
            }
            if(!doc.spring.cloud.stream.bindings) {
                doc.spring.cloud.stream.bindings = {};
            }

            doc.spring.cloud.stream.bindings[`createUpdate${this.entityClass}-Output`] = {
                destination: `createUpdate${this.entityClass}Exchange`,
                contentType: 'application/json'
            }
            doc.spring.cloud.stream.bindings[`delete${this.entityClass}-Output`] = {
                destination: `delete${this.entityClass}Exchange`,
                contentType: 'application/json'
            }

            fs.writeFileSync(configFile, yaml.dump(doc), 'utf8');