0

我创建了多模块项目:

  • (pom)root
    • (罐)libModule
    • (jar) appModule,有libModule依赖关系

appModulepom 有依赖关系:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

它还包含自己的@ConfigurationProperties类:

    @ConfigurationProperties(prefix = "service.test")
    @Component
    @Data
    public class Conf {
        String prop;
    }

编译这个模块会产生下一个正确的spring-configuration-metadata.json文件:

{
  "groups": [
    {
      "name": "service.test",
      "type": "org.test.app.Conf",
      "sourceType": "org.test.app.Conf"
    }
  ],
  "properties": [
    {
      "name": "service.test.prop",
      "type": "java.lang.String",
      "sourceType": "org.test.app.Conf"
    }
  ],
  "hints": []
}

我的 Idea IDE 成功地突出了我的这个属性application.yml

但我还有额外@ConfigurationProperties的课程libModule

@ConfigurationProperties(prefix = "service.a")
@Setter
@Getter
public class ServiceAProperties {
    String url;
}

我试图将此类appModule包含在下一个代码中:


@SpringBootApplication
@ConfigurationPropertiesScan(basePackageClasses = {
        ServiceAProperties.class
})
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }
}

并尝试了不同的方法将它包含到 json 中,但它没有出现在那里。只使用自己的模块Conf

我如何包含来自其他模块的配置属性以生成正确的 json,包括两个模块的属性

如果需要一些额外的信息,请询问

4

1 回答 1

0

好的。我的问题的答案是 - 我必须单独为 libModule 生成 json。应该以这种方式工作

于 2021-12-23T02:24:53.217 回答