Spring boot 配置多模块 [英] Spring boot configuration multi modules

查看:106
本文介绍了Spring boot 配置多模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据其他一些帖子,它看起来应该在顶级聚合器项目中只定义一个 application.properties.

According to some other posts, it looks only one application.properties in the top-level aggregator project should be defined.

然后,在其他模块中,使用@PropertyResource处理相关属性的模块的特定文件.

Then, in other modules, a specific file by module for related properties handled using @PropertyResource.

使用 spring boot 时似乎不支持或未处理属性资源上的通配符?!

假设我们开发了一个引擎应用程序:

Let's imagine we develop an engine application:

模块:引擎核心、引擎通信、引擎启动器(包含 Spring Boot 应用程序的模块).

Modules: engine-core, engine-communication, engine-launcher (module containing the spring boot application).

在引擎启动器模块中,我想定义一个这样的配置:

In the engine launcher module, I would like to define a configuration like this:

<代码>@配置@PropertySource(value = "classpath*:/config/engine-*-config.properties", ignoreResourceNotFound = true)公共类 EngineConfiguration { ... }

模块中有相关的配置文件.执行此操作时,看起来找不到这些配置文件.

With related configuration files in the modules. When doing this, it looks these configuration files cannot be found.

拥有模块化/灵活配置的最佳方式是什么?有任何想法吗?

What's the best way to have a modular/flexible configuration. Any ideas?

推荐答案

看起来 @PropertySource 不支持资源位置的通配符,如以下帖子所述:@PropertySource 中的类路径通配符

It looks @PropertySource does not support wildcard for resource locations as explained in the following post: classpath wildcard in @PropertySource

这篇关于Spring boot 配置多模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆