我创建了多模块项目:
- (pom)
root
- (罐)
libModule
- (jar)
appModule
,有libModule
依赖关系
- (罐)
appModule
pom 有依赖关系:
<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,包括两个模块的属性
如果需要一些额外的信息,请询问